Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在asp.net中使用javascript获取listview中按钮的commandargument_Asp.net - Fatal编程技术网

如何在asp.net中使用javascript获取listview中按钮的commandargument

如何在asp.net中使用javascript获取listview中按钮的commandargument,asp.net,Asp.net,我正在开发一个asp.net应用程序,其中有一个列表视图,其中有一个链接按钮。我想获取listview中按钮的commandargument。我使用了以下代码: <asp:ListView ID="ListView5" runat="server" OnItemDataBound="ListView5_ItemDataBound"> <ItemTemplate> <li> <asp:Image runat="server" Style="w

我正在开发一个asp.net应用程序,其中有一个列表视图,其中有一个链接按钮。我想获取listview中按钮的commandargument。我使用了以下代码:

<asp:ListView ID="ListView5" runat="server" OnItemDataBound="ListView5_ItemDataBound">
 <ItemTemplate>
 <li>

    <asp:Image runat="server" Style="width: 50px; height: 50px;" ID="Image1" ImageUrl='<%#Eval("Image") %>' />
        <asp:HiddenField ID="lblWallID" runat="server" Value='<%#Eval("Wall_ID") %>'></asp:HiddenField>
        <p>
         <asp:LinkButton ID="linkID" runat="server" CommandArgument='<%#Eval("UID") %>'>
           <asp:Label ID="lbl1" runat="server" Text='<%#Eval("Full_Name") %>'></asp:Label>
   </asp:LinkButton>
  </p>
 <p>
     <asp:Label ID="Label1" runat="server" Text='<%#Eval("Wall_Content") %>'></asp:Label>
</p>
 <p>
     <asp:Label ID="lblTime" CssClass="time-text" runat="server" Text='<%#Eval("TimeAgo") %>'></asp:Label>
</p>

<p>

        <asp:LinkButton ID="btnClick" runat="server" Text="Comment" OnClientClick="SaveCom(this);" CommandArgument='<%#Eval("Wall_ID") %>' CommandName="Comment"></asp:LinkButton>
                                                    </p>

                                                 </li>
                                    </ItemTemplate>
                                </asp:ListView>

  • Javascript函数是:

    <script type="text/javascript">
            function SaveCom() {
                var val = $(this).commandargument();
    </script>
    
    
    函数SaveCom(){
    var val=$(this.commandargument();
    
    在代码隐藏中使用
    OnItemCommand=“EmployeesListView\u OnItemCommand”
    事件。我想使用javascript获取Commandargument,那么我们该怎么做。请帮助我,您无法在客户端获取Commandargument,因为它是针对服务器而不是客户端的。如果仍然要这样做,则必须解析viewstate(非常糟糕的想法)