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?
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?
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
data-
. So you'd have data-cmdname
. See tinyurl.com/6uycchj –
Fontana 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.
The short answer is NO if you are ONLY using javascript. But you could retrieve it with an ajax call to the server or using a hidden field like J.W. suggested. This property is not even accessible from themes. For more info read the documentation in msdn
JS :
------
function get_id(obj) {
var my_eval = obj.getAttribute("name");
alert(my_eval);
}
<input type="button" id="btn" value="My Btn" onclick="get_id(this);" name='<%# Eval("item_id") %>' />
© 2022 - 2024 — McMap. All rights reserved.