Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can i get the button's command argument?

Is it possible to get a button's command argument in javascript. I don't want to manipulate it, i just want to read it.

If possible - how?

like image 797
Eric Avatar asked Oct 14 '09 17:10

Eric


2 Answers

Make your own attribute and get it with standard JavaScript:

Markup:

<asp:LinkButton ID="LinkButton1" cmdname="test" CommandName="test" CommandArgument="1" 
    runat="server" onclick="LinkButton1_Click">LinkButton</asp:LinkButton>

Script:

//however you choose to get the element, jQuery...etc
document.getElementById('<%=LinkButton1.ClientID %>').cmdname
like image 136
rick schott Avatar answered Oct 16 '22 22:10

rick schott


You can put command argument into some hidden field, then retrieve the value of the hidden field in javascript after page loads such as $(document).ready() in JQuery.

like image 25
J.W. Avatar answered Oct 16 '22 23:10

J.W.