1

I am using ryanfait.com custom form elements to change the appearance of my dropdown lists in my .net web application. Everything works fine except for .net postbacks on dropdown lists. Having looked at the javascript code for custom work elements I have noticed that the onchange event is overwritten:

    if(!inputs[a].getAttribute("disabled")) {
    inputs[a].onchange = Custom.choose;
    } else {
    inputs[a].previousSibling.className = inputs[a].previousSibling.className += " disabled";
    }

If I comment out the above code the autopostback works but for other dropdownlists which do not require an autopostback the input value now does not change. Is there a way I can get this working for both scenarios? On ryanfait.com he says:

onChange and other JavaScript events This script utilizes JavaScript's onChange and other events. Because these events can only be used once, if you want to add more functions to an event, you will need to call them from inside my script.

But I can't work out if I can somehow trigger the autopostback event?

Any help would be very much appreciated!

4

1 回答 1

0

最简单的方法是添加带有自动回发功能的标准 asp:dropdownlist,预览页面然后查看源代码,在 HTML 源代码中找到列表并复制 onChange 属性。这是您需要调用客户端才能将页面发回的内容。

例如。

onchange="javascript:setTimeout('__doPostBack(\'ddlHolidayType\',\'\')', 0)"
于 2015-06-25T10:31:00.613 回答