///
/// Add a new event handler for the Load Event
///
public ${Record Control}()
{
// The following line will be inserted inside the
// constructor for page class.
this.Load += new System.EventHandler(${Record Control}_Load);
}
///
/// Overrides SelectedIndexChanged event to redirect to another page.
///
protected override void ${Dropdown List Control}_SelectedIndexChanged(object sender, EventArgs args)
{
// retrieve the selected value of dropdown list control.
string selectedValue = this.${Dropdown List Control}.SelectedItem.Text;
// Add custom code to check for the value. Here is an example of a switch statement for multiple
// redirects when certain values are selected for the dropdown list.
switch (selectedValue) {
// Here replace value1, value2 with actual values
case "value1":
this.Page.Response.Redirect("../OtherPages/SomeOtherPage1.aspx");
break;
case "value2":
this.Page.Response.Redirect("../OtherPages/SomeOtherPage2.aspx");
break;
default:
this.Page.Response.Redirect("../OtherPages/SomeOtherDefaultPage.aspx");
break;
}
}
///
/// This method sets up a event handler for a selected index changed event.
///
private void ${Record Control}_Load(object sender , System.EventArgs e)
{
this.${Dropdown List Control}.AutoPostBack = true;
this.${Dropdown List Control}.SelectedIndexChanged += new System.EventHandler(${Dropdown List Control}_SelectedIndexChanged);
}
|