将服务器控件的值传递给ASPx客户端事件

时间:2022-05-02 15:46:12

I have a ComboBox in my page:

我的页面中有一个ComboBox:

<dx:ASPxComboBox ID="comboSiteID" runat="server" style="margin-bottom: 0px" ValueField="name" Width="120px"></dx:ASPxComboBox>

When the user select an item from this combobox, i want to query MSSQL and show the returning value on a label:

当用户从这个组合框中选择一个项目时,我想查询MSSQL并在标签上显示返回值:

<dx:ASPxLabel ID="ASPxLabel1" runat="server" Text="Value is here"></dx:ASPxLabel>

It seems that the client side event is the appropriate one to put my code

似乎客户端事件是放置我的代码的合适的事件

<clientsideevents TextChanged="function(s, e) {
    // What to do?
}" />

What is the best way to succeed this task?

完成这项任务的最佳方法是什么?

1 个解决方案

#1


2  

If you do it client-side, then you need to call a web service, have that web service query the database, and return the results via JSON. Is that really what you are looking to do? If you are, the webservice is the trick.

如果您在客户端执行此操作,则需要调用Web服务,让该Web服务查询数据库,并通过JSON返回结果。这真的是你想要做的吗?如果你是,网络服务就是诀窍。

Or, you can set AutoPostBack="true", the page posts back to the server, and from there query the DB and load the results in the label.

或者,您可以设置AutoPostBack =“true”,页面回发到服务器,然后从那里查询数据库并将结果加载到标签中。

#1


2  

If you do it client-side, then you need to call a web service, have that web service query the database, and return the results via JSON. Is that really what you are looking to do? If you are, the webservice is the trick.

如果您在客户端执行此操作,则需要调用Web服务,让该Web服务查询数据库,并通过JSON返回结果。这真的是你想要做的吗?如果你是,网络服务就是诀窍。

Or, you can set AutoPostBack="true", the page posts back to the server, and from there query the DB and load the results in the label.

或者,您可以设置AutoPostBack =“true”,页面回发到服务器,然后从那里查询数据库并将结果加载到标签中。