想要在Javascript中触发Dropdown SelectedIndexChanged事件

Muh*_*tar 5 html javascript asp.net javascript-events

我在我的页面上有下拉列表,我正在使用javascript从弹出窗口更改下拉列表的选定值.我在下拉列表中有一些逻辑SelectedIndexChanged事件,所以我需要在从javascript更改下拉列表选项时触发SelectedIndexChanged事件.

小智 9

document.getElementById('<%= yourDropdown.ClientID %>').onchange();
Run Code Online (Sandbox Code Playgroud)

这应该有效,如果你仍然遇到一些错误,你可以尝试这样:

setTimeout('__doPostBack(\'yourcontrolClientSideID\',\'\')', 0);
Run Code Online (Sandbox Code Playgroud)

yourcontrolClientSideID 是呈现的客户端ID的ID.