Click here to Skip to main content
15,896,201 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm sorry but I little English.. :)

I have one question..

I use UpdatePanel For Async PostBack Process

I want mapping Server Click Event For DIV HTML Element,

I searched How can I mapping Server Click event DIV HTML Element.

I find any solution. but the solution coudn't Async PostBack.

the solution did Page Refresh.

How Can I Mapping Server Click Event The Div HTML Element For Async PostBack?


If you fine, Code Sample Write Please, Thank You :D

English is little difficult, I will learn hard!!
Posted
Updated 27-Mar-11 23:08pm
v5
Comments
Sunasara Imdadhusen 28-Mar-11 5:11am    
What dose it means "I mapping Server Click event DIV HTML Element"?
aksaeful 29-Mar-11 9:52am    
I'm sorry, I little English,

it means Server Side Event Handlers for DIV Click

Thank you for try help me :D
[no name] 28-Mar-11 5:30am    
Are you speaking about Server Side Event Handlers for Div Click?
aksaeful 29-Mar-11 9:53am    
Yes, It is. :D

1 solution

You can handle the click event on a DIV as the code following (div1 is the id of the DIV element)
public partial class _Default : System.Web.UI.Page, IPostBackEventHandler
{ 
protected void Page_Load(object sender, EventArgs e)
{
div1.Attributes["onclick"] = ClientScript.GetPostBackEventReference(this, "ClickDiv");
}
protected void Div1_Click()
{
// Do something
}
#region IPostBackEventHandler Members
public void RaisePostBackEvent(string eventArgument)
{
if (!string.IsNullOrEmpty(eventArgument))
{
if (eventArgument == "ClickDiv")
{
Div1_Click();
}
}
}
#endregion
}


Hope this might help you, if it is server side event handler for Div click.
 
Share this answer
 
Comments
aksaeful 28-Mar-11 21:13pm    
Thank you for great answer :D

And I think this solution not support Async PostBack,

This Solution has Page Refresh, But your help was great!

Thank you so much~!
[no name] 28-Mar-11 23:46pm    
Its my pleasure.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900