我怎样才能按钮的命令参数?按钮、命令、参数

2023-09-03 02:53:19 作者:暴走の少女梦

是否有可能获得在JavaScript按钮的命令参数。我不想操纵它,我只是想读它。

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.

如果可能的 - 如何

推荐答案

请自己的属性,并把它与标准的JavaScript:

Make your own attribute and get it with standard JavaScript:

标记:

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

脚本:

//however you choose to get the element, jQuery...etc
document.getElementById('<%=LinkButton1.ClientID %>').cmdname