asp hyperlink click event?

  • Thread starter Thread starter Doug Stiers
  • Start date Start date
D

Doug Stiers

I have an asp:hyperlink that I need to have some code fire when the link is
clicked. The link is in a datagrid and the link is working properly. I tried
using the OnInit event to call the subroutine but that fires when the
control is rendered. I need the code to fire only when the users clicks on
one of the links in the datagrid.

Any help would be appreciated,
Doug
 
asp:hperlink emits a pure <a href > and doesnt have any server side events
based on my experience (can be wrong)

if you need to execute server side code then use linkButton... this cause a
postback on click and you can do all you want

HTH

HD
 
Hi, Doug,

ASP:Hyperlink doesn't have a server Click event. Init
event occurs when the server control is initialized, which
is the first step in the its lifecycle. This is fired even
before it is rendered.
If you need a server Click event, use LinkButton in stead.
If you need a client onclick event, do like the following:
Hyperlink1.Attributes("onclick") = "javascript:alert('The
hyperlink is clicked!');"

Bin Song, MCP
 
Back
Top