Passing additional arguments into the OnClick event handler of a LinkButton using Javascript

Posted by Jens Ameskamp on Stack Overflow See other posts from Stack Overflow or by Jens Ameskamp
Published on 2010-03-12T13:45:30Z Indexed on 2010/03/12 13:47 UTC
Read the original article Hit count: 357

Filed under:
|

Hi!

I have a ASP.NET Website, where, in a GridView item template, automatically populated by a LinqDataSource, there is a LinkButton defined as follows:

<asp:LinkButton ID="RemoveLinkButton" runat="server" CommandName="Remove"
                CommandArgument='<%# DataBinder.GetPropertyValue(GetDataItem(), "Id")%>'                                 
                OnCommand="removeVeto_OnClick"
                OnClientClick='return confirm("Are you sure?");'
                Text="Remove Entry" />

This works fine. Whenever the Button is Clicked, a confirmation dialog is displayed.

What I am trying to do now, is to allow the user to enter a reason for the removal, and pass this on the the OnClick event handler. How would I do this? I tried OnClientClick='return prompt("Enter your reason!");', but, of course, that did not work =)

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about JavaScript