Sunday, February 7, 2010

jQuery - simulating a C# dropdownlist OnSelectedItemChanged event

To do a simulation of the C# code-behind event of the dropdownlist; OnSelectedItemChange. Simply do the following:-

1. Create a drop down list and ensure that the CssClass attribute contains some value. For the purpose of this example, I'll name it "ddlChange"

eg:
<asp:DropDownList ID="[Your DDL name here]" runat="server" CssClass="ddlChange"></asp:DropDownList>


2. Create a javascrpit tag and add the following code in it.
$(".ddlOrderType").change(function() {
//Insert any logic you require here.
});

No comments:

Post a Comment