How do you call a C# function from an ASP.NET event?
I have written a function in my .cs page. On the event onselectedindexchanged in .aspx I want to call this func开发者_JAVA技巧tion.
How do I do this?
If you had the following method in your *.cs file:
public void DoSomething()
{
}
You could wrap the call in an event handler:
void RadioButtonList1_IndexChangedHandler(object sender, EventArgs e)
{
DoSomething();
}
And your *.aspx code would look like:
<asp:RadioButtonList id="RadioButtonList1"
OnSelectedIndexChanged="RadioButtonList1_IndexChangedHandler"
AutoPostBack="true"
runat="server"/>
Just point this function to onselectedindexchanged
property of the drop down list.
onselectedindexchanged="DropDownList1_SelectedIndexChanged"
Can you also explain how you added the Drodown List to the page?
With the <%= %> tags
<%= Function() %>
精彩评论