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
Solved

click on anchor tag - detect in code behind

Posted on 2013-02-05
1
1,565 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:knowlton
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

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

837 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