Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

hyperlink onclick

Status
Not open for further replies.

silecen

Programmer
Aug 15, 2007
4
TR
Hi
how can I achieve to fire MyFunction on HyperLink's onClick event ?

Code:
HyperLink1.Attributes.Add("OnClick",  "MyFunction();") ;
public void MyFunction() 
    {
        Label1.Text = "Hello";
    }
 
forum855 would be a better place to post this.
however what you have posted above will not work. attributes refer to client attributes (js, css, html) your code is server code, which knows nothing about the client.

hyperlinks are not buttons this is by design. instead use a LinkButton (looks like a link behaves like a button).

use the asp.net server control properties whenever possible and avoid the Attributes.Add(); this will make debugging much easier.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top