Click here to Skip to main content
15,923,689 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
HI,

I have a asp hidden field, and i need to set a value using javascript. And this javascript is in a js file not in the web page.

And i include the js to this web page


When i used below code, it is not working.


JavaScript
document.getElementById("<%= Order_ID.ClientID %>").value = "abc";



How can i set a value to hidden field, Help Me Please.


Thanks

Dileep
Posted
Comments
Anuja Pawar Indore 23-Aug-12 5:30am    
Are you using update panel on this page?
srmohanr 3-Feb-14 5:12am    
I am using update panel. How to achieve this.

Try this.

javascript:
JavaScript
function SetHdnField() {
            var x = document.getElementById('<%= hdnSomeField.ClientID %>');
            x.value = 'hi';
            return false;
        }

aspx:
XML
<asp:HiddenField runat="server" ID="hdnSomeField" />
   <br />
   <asp:Button runat="server" ID="btnSetValue" Text="Set Value" OnClientClick="return SetHdnField();" />


This works fine for me.
 
Share this answer
 
Comments
dilzz 23-Aug-12 6:47am    
Thanks
santhudotnet 23-Jul-13 10:01am    
it's not working properly
 
Share this answer
 
HI ,

document.getElementById('textBox1').value = "Yes"
 
Share this answer
 
Comments
dilzz 23-Aug-12 5:13am    
its not working
santhudotnet 23-Jul-13 10:02am    
where is the remanining code da...(yeruma)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900