C# .NET - Call server side click event on anchor tag's click

Asked By Shailendrasinh Parmar on 25-Mar-10 12:21 AM
Hello Guys,

I have pop-up page in Thickbox, And I am using <area> tag in that popup.aspx page.

Now in page source, the <area>  tag is replaced by simple anchor tag...

Now the problem is I want to call a server side Click Event on that <area> tag's click.

Can you please give me some idea, how can I do this... I tried several ways but couldn't get it.

I also used LinkButton instead of <area> but, it works only in FF not in IE and Chrome...

Please help.
Huggy Bear replied to Shailendrasinh Parmar on 25-Mar-10 12:27 AM
LinkButton should work on IE and Chrome. The only dependency would be is make sure the javascript is enabled on those browsers.
Sreekumar P replied to Shailendrasinh Parmar on 25-Mar-10 12:42 AM
hi,

 <a href="#" onclick=<% = Page.ClientScript.GetPostBackClientHyperlink(Button1, "") %> >Click Here</a>

Web Star replied to Shailendrasinh Parmar on 25-Mar-10 12:44 AM
u can do this using __doPostback

First consider that the Link button is rendered as :

<a id="LinkButton1" href="javascript:__doPostBack('LinkButton1','')">LinkButton</a>


details is here http://forums.asp.net/p/1519048/3644158.aspx
Shailendrasinh Parmar replied to Web Star on 25-Mar-10 01:37 AM
Thanks you all guys.. 

But I solved the issue using PageMethods and WebMethod from the following article

http://www.dotnetcurry.com/ShowArticle.aspx?ID=109

Thank you so much..
Vardhin replied to Shailendrasinh Parmar on 23-Sep-11 12:56 AM

One workaround could be :

invoke dummyButton click in client side event of anchor tag - which will call server side event of this dummy Button by default. so if u place ur server side code in this dummyButton server event - calling anchor tag client side event would invoke this server side dummy button event.

Code:

<a id="ancLink" href="javascript:void(0);" >back</a>

<asp:Button ID="dummyRefresh" runat="server" OnClick="BtnRefreshOnclick" style="display:none"/>

Javascript:

ancLink.live("click", function () {
     callDummyButtonServerEvent();
    });

function callDummyButtonServerEvent() {
  
    $('input[id$=dummyRefresh]').click();   
  
}

Hope this helps.

Vardhini