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.
protected void Page_Load(object sender, EventArgs e)  
{  
    ListBox1.Attributes.Add("ondblclick", ClientScript.GetPostBackEventReference(ListBox1, "doubleClickEvent"));  
    if (Request["__EVENTARGUMENT"] != null && Request["__EVENTARGUMENT"] == "doubleClickEvent")  
    {  
        //Write your code to handle the Double Click Event  
    }  
}  

No comments:

Post a Comment