User-1142886626 posted
Hi Silvers,
The problem now is that I will have about 200 dropdownlists and 200 buttons and like to avoid putting all of them in the "<Triggers>".
Maybe you could use JavaScript function to achieve this. You could use jquery selector find all button and dropdownlist on your page, then bind the event.
It might also be noted that some JavaScript function should be put in the UpdatePanel.
Code below is for your reference:
<script type="text/javascript">
function BindEvent() {
$(function () {
$(":submit").bind("click", function () {
alert("asd");
})
$("select").bind("change", function () {
var tx=$(this).find("option:selected").text();
if (tx== 1) {
alert(1);
} else if (tx== 2) {
alert(2);
}
})
})
}
</script>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<script type="text/javascript">
Sys.Application.add_load(BindEvent);
</script>
<asp:Button ID="Button1" runat="server" Text="Button" /><br />
<asp:Button ID="Button2" runat="server" Text="Button" /><br />
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem>select</asp:ListItem>
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="DropDownList2" runat="server">
<asp:ListItem>select</asp:ListItem>
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
</asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
Best Regards,
Ailleen