Get Value of Hidden Field in Client Side

前端 未结 6 1882
挽巷
挽巷 2021-02-07 04:04

On a button click on my server side, I assign value to the Hidden Field from a column in my table.

Dim dsGetEnquiryDetails = dbl.usp_GetEnquiryRegisterDetails(Va         


        
相关标签:
6条回答
  • 2021-02-07 04:14

    Assuming that it's not null you don't use the hiddenfield's value proprty:

    var statusFlag = '';
    var hiddenStatusFlag = document.getElementById('<%= HiddenStatusFlag.ClientID%>');
    if(hiddenStatusFlag != null)
    {
        statusFlag = hiddenStatusFlag.value;
    }
    
    0 讨论(0)
  • 2021-02-07 04:16

    That returns the input. You need the value of the hidden input.

    StatusFlag = document.getElementById('<%= HiddenStatusFlag.ClientID%>').value;
    
    0 讨论(0)
  • 2021-02-07 04:20

    in jquery:

    var hiddenValue = $('#hiddenFieldID').val();
    
    0 讨论(0)
  • 2021-02-07 04:26

    If your hiddenfield used runat="server"

    Use this code:

    StatusFlag = document.getElementById('<%= HiddenStatusFlag.ClientID%>').value; 
    

    else use this code:

    StatusFlag = document.getElementById("HiddenStatusFlag").value;
    
    0 讨论(0)
  • 2021-02-07 04:29

    in javascript:

    var SomeVar = document.getElementById('HiddenField_ID').value;
    StatusFlag = SomeVar;
    
    0 讨论(0)
  • 2021-02-07 04:31
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
    <title></title>
     <script type="text/javascript" language="javascript">
    alert(document.getElementById("<%= Hiddenfield1.ClientID %>").value);
    </script>
    </head>
    <body>
    
    <div>
    <asp:hiddenfield ID="Hiddenfield1" runat="server" value="Hussain Testing"></asp:hiddenfield>
    </div>
    <body>
    
    </html>
    
    0 讨论(0)
提交回复
热议问题