Objects in this mirror are closer to Microsoft Technologies. DNM objective is to help users on Microsoft technologies by providing Articles, snippets, Interview Questions.

12 September 2012

javascript not setting the hidden field value in ASP.NET


Today when i tried to change the value of hidden filed in java script, its not setting the value. I am using master page for an ASPX page.



<asp:HiddenField ID="hdnTest" runat="server" Value="Before JS Call" />



In java script method, when I try to assign the value it’s not getting replaced with new value.




document.getElementById('<%=hdnTest.ClientID%>').value = 'After JS Call';

then i replaced with below code

document.getElementById('ContentPlaceHolder1_
hdnTest').value = 'After JS Call';


and it worked out.

Not sure with the reason but its resolved!

1 Comments:

K.Nageswara said...

Instead for Doing like this. In Jquery You can simply get it. Like

$('#hdnValue').val("Some Text");

Post a Comment