I want to assign mouseclick event to asp.net panel:
protected void Page_Load(object sender, EventArgs e)
{
Panel p = new Panel();
p.Click += new EventHandler(b_Click);//but, this doesn't compiles correctly
}
protected void b_Click(object sender, EventArgs e)
{
//C#code
}
Is there any way to add click event to panel?
Here is what you can do to make your panel clickable and handle the event at server side.
Place panel in your web form
Add jQuery script library to your page.
Define the following client side event handler
Handle the event at server side.
The code in PreRender event handler is for asp.net framework to render __doPostBack function at cilent sides. If your page includes a control that causes an auto postback you don’t need this code.