• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 179
  • Last Modified:

capturing which link was clicked on so that I can dynamically build page header text.

I need to dynamically change/assign certian text elements in my page headers depending upon which hyperlinks my users click on. I have a page header, left navigation bar and footer. All of these sections are built using pagecontrols.

The header section in turn inherits two pagecontrols. One page control is for the navigation, the other is photo and text material. It is this photo and text material that I would like to change based upon which hyperlink is clicked in the web site. In order to do this, I believe I need to find a way to capture the link click event and then change the header pagecontrol text and photo content based upon this information.

Thanks for any help or suggestions with this.

2 Solutions
For a small number of predefined links, use the asp:linkbutton control for your hyperlinks and capture the click event for each link. If you've built page controls, this should be straightforward for you. You could build a helper function, called by each click handler to do the dirty work.

Even for an unknown or variable number of links (db generated), this approach could work. As you generate the links on the page, assign the click event for each link to the same event handler.

LinkButton link;
foreach (data in some table)
  link = new LinkButton();
  link.Text = "My text";
  link.Click += new EventHandler(this.LinkClickHandler);

private void LinkClickHandler(object sender, System.EventArgs e)
     LinkButton clickedLink = (LinkButton)sender;
     string linkText = clickedLick.Text;
Look into the method:

It tells you the URL from which page the user came from.

wmsunderAuthor Commented:
Problem was solved with an unrelated work-around. Points split and awarded to the two respondants.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now