Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

301
Visualizações
How to access hidden field value from java script code(Client side) in asp.net c#

I have defined hidden field in .aspx page(ui)

 <asp:HiddenField ID ="hdnExport" runat="server" />

Set the value in the following code (java script)

$(document).ready(function () {
            $("#btn_FinalConfirmOK").on("click", function (event) {
                alert("clicked");
                //document.getElementById("hdnExport").value = "yes";
                $('#hdnExport').val("yes");
               
                alert($('#hdnExport').val());

                document.getElementById('hdnExport').value = "yes";
                //alert("yes");
            });
        });

Then accessing hidden field value in aspx.cs code is given below,

string exportValue = Convert.ToString(hdnExport.Value);
        string exp = hdnExport.Value.ToString();
        var val = this.hdnExport.Value;
        string latitudeValue = Request.Form[hdnExport.Value];

Tried with different ways. but i didn't get value from hidden field. how to solve this issue

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

By default, the rendered id will differ from the ID specified within C# (hdnExport). Therefore, (#hdnExport) is likely an invalid selector thus no value is set.

Try setting ClientIDMode="Static" on the HiddenField:

 <asp:HiddenField ID ="hdnExport" ClientIDMode="Static" runat="server" />

This will ensure the hidden field is rendered with id as ID which would make #hdnExport valid.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda