Solved

click on anchor tag - detect in code behind

Posted on 2013-02-05
1
1,587 Views
Last Modified: 2013-02-05
On a web form, when I click on an anchor tag, is there a way I can respond to this event in the code behind, not of the page I am about to go to, but the page that has the anchor tag?
0
Comment
Question by:Tom Knowlton
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 20

Accepted Solution

by:
Daniel Van Der Werken earned 500 total points
ID: 38856051
Set the anchor tag to runat="server"

then, in the code behind, work with the .ServerClick() event:

<html>
<a id="myAnchorTag" href="something" runat="server">Click me</a>
</html>

In the .cs:

In the OnInit or Page_Load method:

myAnchorTag.ServerClick() += new SomeEventHandler( object sender, EventArgs e );

Then, of course, you need the implement the event.

Reference: http://msdn.microsoft.com/en-us/library/system.web.ui.htmlcontrols.htmlanchor.serverclick.aspx
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question