Link Button Javascript!!!

A

Adam Knight

Hi all,

<asp:linkbutton id="lbtnRemSuperintendent" runat="server"
CausesValidation="False" CssClass="drkLink">- Remove</asp:linkbutton>

Is there any way to declaratively add a javascript on click event to a link
button???

As far as i know using the OnClick property will initiate a server side
event....

Cheers,
Adam
 
H

HoustonFreeways

As far as I know, you cannot add a client-side event in the linkbutton tag.
You need to add it via an attribute in the Page_Load (or other server-script
event)
lbtnRemSuperintendent.Attributes.Add("onclick", "alert('message');");

If you really want to add it in the tag, you should be able to derive a
special control which has a property (such as "client_onclick") which adds
the script as an attribute.

Another option is to use an anchor tag (<a runat=server...></a>) The onclick
attribute is for the client event, and the onserverclick is for the server
event. In general, HTML controls are better for easily adding client script.
 
J

Jay Sanderson

Try placing a <SPAN onclick="do javascript stuff here as normal"> around
your link button

I use this method to do confirms on deletes....
 

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

Top