开发者

How to enable html select post back apsx page when selection changed?

开发者 https://www.devze.com 2022-12-29 13:09 出处:网络
With asp.NET control dropdownlist, there is a property A开发者_开发百科utoPostBack, if it is set \"True\", the whole page will be posted back.

With asp.NET control dropdownlist, there is a property A开发者_开发百科utoPostBack, if it is set "True", the whole page will be posted back.

If the aspx page include a html element "select" like:

<select id="list" name="list" runat="server"
    DataTextField="Name" DataValueField="ID" ></select>

and it data is filled by code-behind.

Question is: how to allow this Select have AutoPostBack function too?


The DropDownList approach adds a __doPostBack('selectelementname', 'commandname'); call to the onchange event. When you change the value, this then proceeds to post back to the server, and then the ASP.NET control processes the postback data in LoadPostData method.

HTH.


You can't apply Auto post back property for html select control.To invoke function writen inside c# code page(serverside),you need to use webservice. You can call javascript function(client side) on 'onchange' event of html select control.

0

精彩评论

暂无评论...
验证码 换一张
取 消