[ACCEPTED]-execute serverside code on div click-vb.net

Accepted answer
Score: 17

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>
Score: 3

Check out this post raise postback event from div tag

Yours would look something 2 like

<div id="c" onclick="__doPostBack('loadContentFamily','')">


Try something like

        <asp:AsyncPostBackTrigger ControlID="c" EventName="Click" />

It's explained better 1 here Partial postback with Javascript

Score: 3

wrap your div inside a LinkButton control 3 and call your loadContentFamily method on 2 OnClick event of LinkButton. This worked 1 for me

Score: 1

I would recommend not using the UpdatePanel 2 control, but jQuery. You can find an example 1 here

Score: 0

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