473,387 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

asp hyperlink click event?

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
Nov 18 '05 #1
2 7919
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

"Doug Stiers" <st****@email.com> wrote in message
news:OO**************@TK2MSFTNGP11.phx.gbl...
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

Nov 18 '05 #2
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

-----Original Message-----
I have an asp:hyperlink that I need to have some code fire when the link isclicked. The link is in a datagrid and the link is working properly. I triedusing the OnInit event to call the subroutine but that fires when thecontrol is rendered. I need the code to fire only when the users clicks onone of the links in the datagrid.

Any help would be appreciated,
Doug
.

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: ashoo | last post by:
Guys! I am trying to use a dropdownlist click event in my header page to link to my main page in a frameset type of form. I try to link to my main page with a hyperlink control.It works fine....
4
by: | last post by:
Does anyone know how to trigger the click event of a hyperlink control programmatically? Thanks for helping.
2
by: Big E | last post by:
I'm using ASP.Net and SQL Server. I have a table called states. I have 2 forms. On form 1 is the 50 states in textboxes created with a loop. I want to have those 50 or 45 or whatever amount of...
1
by: Daniel | last post by:
Hi All, Does anyone know to send click event to the hyperlink?? What i mean is the user click on the button and the hyperlink click event will be trigger instead of persoanlly click on the...
19
by: Joe | last post by:
I have an aspx page (referred to here as page_1) with a datagrid whose first column contains hyperlinks. When a user clicks one of these hyperlinks, he will navigate to another aspx page (referred...
2
by: Keith Wilby | last post by:
A2003, XP Pro. I have a text box on a form. The text box is bound to a hyperlink field. I want to use the contents of the text box in code so I'm assigning the contents to a string variable. ...
0
by: lechatthierry | last post by:
Is it possible to block a mouse event on an Hyperlink with a general script event? This is quite troublesome for me. I am trying to find a way to block the windows shortcut SHIFT + MOUSE LEFT...
1
by: Neko | last post by:
Is it possible to block a mouse event on an Hyperlink with a general script event? This is quite troublesome for me. I am trying to find a way to block the windows shortcut SHIFT + MOUSE LEFT...
6
by: mramsay | last post by:
Hi, I am lost when it comes to creating a click event in asp. I have hyperlinks that are pulled dynamically from a table. An example is Hockey is a hyperlink. What I want to do is when a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.