Assign JavaScript values to C# Variable

后端 未结 2 1135
春和景丽
春和景丽 2021-01-06 23:53

I have a Javascript function that pulls down variables, like so:

   function OnClientCloseSecure(oWnd, args) {
       var arg = args.get_argument();

                


        
相关标签:
2条回答
  • 2021-01-07 00:44

    JavaScript

    <script type="text/javascript">
        function OnClientCloseSecure(oWnd, args) {
            var arg = args.get_argument();
            if (arg) {
                var ResultCode = arg.ResultCode;
                var PONumber = arg.PONumber;
                document.getElementById('<%=lbl.ClientID %>').innerHTML = ResultCode;
            }
        }
    
    </script> 
    

    Mark Up

    <asp:Label ID="lbl" runat="server" ></asp:Label>
    
    0 讨论(0)
  • 2021-01-07 00:56

    One way would be to create hidden value and set the runat attribute to server. you can get the value.

        <script type="text/javascript">
       function abc() 
        { 
          var str="value"; 
          document.getElementById("Hidden1").value=str; 
        } 
    
        </script> 
    
    <input id="Hidden1" type="hidden" runat="server" />
    

    Code Behind:

        string value = Hidden1.Value;
    
    0 讨论(0)
提交回复
热议问题