Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 435
  • Last Modified:

asp.net webform

I am developing a asp.net website using visual basic 2008 I am using html not server controls to navigate from one webform to another. I want to somehow capture the event clicking of the html link so I can determine what webform is opening so that I can save the appropiate session variables. The problem is using html links to navigate I have no idea how to accomplish that. So any help on trying to figure this out would greatly be appreciated
0
lothos123452000
Asked:
lothos123452000
  • 2
  • 2
1 Solution
 
smokingspacemanCommented:
You mean you use HTML <a> tags for navigation?
If so make change the runat attribute of the <a> tag to server.
<a id="link" href="sdfs.aspx" runat="server">link</a>

And you can add an event handler to the on click event of that control;
    Protected Sub link_click(ByVal sender As Object, ByVal e As System.EventArgs) Handles link.ServerClick
0
 
lothos123452000Author Commented:
What if my html looks like the following

<li><a href="ContactUs.aspx" runat="server">Contact Us</a></li>

I have a space between Contact and Us it is not working plus I get the following error

"Handles clause requires a WithEvents variable defined in the containing type or one of its base types."
0
 
lothos123452000Author Commented:
Never mind about my second post your suggestion worked great! Thanks for the help.
0
 
smokingspacemanCommented:
The problem is you dont have an Id for your <a> tag.
It should be
<li><a id="contactUs" href="ContactUs.aspx" runat="server">Contact Us</a></li>
and
Protected Sub link_click(ByVal sender As Object, ByVal e As System.EventArgs) Handles contactUs.ServerClick
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

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