Thursday, January 24, 2013

Add a new event to server control in asp.net

Server controls in asp.net may not have all required events. But we can add additional javaScript events. So here i have provided a example to add a "Double Click" event in ListBox control.
  1. protected void Page_Load(object sender, EventArgs e)
  2. {
  3. ListBox1.Attributes.Add("ondblclick", ClientScript.GetPostBackEventReference(ListBox1, "doubleClickEvent"));
  4. if (Request["__EVENTARGUMENT"] != null && Request["__EVENTARGUMENT"] == "doubleClickEvent")
  5. {
  6. //Write your code to handle the Double Click Event
  7. }
  8. }

No comments:

Post a Comment