How can I get a button command argument?

Is it possible to get button command argument in javascript. I do not want to manipulate it, I just want to read it.

If possible, how?

+4
source share
3 answers

Create 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 
+19
source

You can put the command argument in some kind of hidden field, and then get the value of the hidden field in javascript after loading the page, for example $ (document) .ready () in jQuery.

+1
source

The short answer is NO if you are ONLY using javascript. But you can get it using an ajax call on the server or using a hidden field such as JW suggested. This property is not even available from themes. Read the documentation in msdn for more information .

0
source

Source: https://habr.com/ru/post/886195/


All Articles