[ACCEPTED]-execute serverside code on div click-vb.net
You need to raise a server event, not client 9 event (and it looks like you want to do 8 that asynchronously).
This article explains how to attach 7 a snippet of code to a client element (like 6 a DIV
) and cause an asynchronous postback.
Another 5 quick and dirty way of accomplishing this 4 is to use a hidden server button. The button 3 can be located wherever desired (such as 2 inside an UpdatePanel
) and it allows proper usage of 1 the ASP page lifecycle.
<asp:Button runat="server" id="btnPostback" style="display:none" onclick="serverEventHandler" />
<div onclick="document.getElementById('<%= btnPostback.ClientID %>').click()">Clickable DIV</div>
Check out this post raise postback event from div tag
Yours would look something 2 like
<div id="c" onclick="__doPostBack('loadContentFamily','')">
Family
</div>
Edit:
Try something like
<Triggers>
<asp:AsyncPostBackTrigger ControlID="c" EventName="Click" />
</Triggers>
It's explained better 1 here Partial postback with Javascript
wrap your div inside a LinkButton control 3 and call your loadContentFamily method on 2 OnClick event of LinkButton. This worked 1 for me
I would recommend not using the UpdatePanel 2 control, but jQuery. You can find an example 1 here
Other alternative is to call a Javascript 3 function and then make a page method call 2 . return data in form of xml & render 1 in the div .
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.