asp hyperlink click event?

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
 
H

Hermit Dave

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
 
B

Bin Song

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top