选择更改时如何启用 html select 回发 apsx 页面?

发布于 08-31 06:37 字数 314 浏览 12 评论 0原文

在asp.NET控件dropdownlist中,有一个属性AutoPostBack,如果设置为“True”,则整个页面将被回发。

如果aspx页面包含一个html元素“select”,例如:

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

并且它的数据由代码隐藏填充。

问题是:如何让这个Select也具有AutoPostBack功能?

With asp.NET control dropdownlist, there is a property AutoPostBack, 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

祁梦2024-09-07 06:37:14

DropDownList 方法添加了 __doPostBack('selectelementname', 'commandname');调用 onchange 事件。当您更改该值时,将继续回发到服务器,然后 ASP.NET 控件在 LoadPostData 方法中处理回发数据。

HTH。

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.

雨轻弹2024-09-07 06:37:14

您不能对 html select 控件应用自动回发属性。要调用 c# 代码页(服务器端)内编写的函数,您需要使用 web 服务。您可以在 html 选择控件的“onchange”事件上调用 javascript 函数(客户端)。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文