Skip to content Skip to sidebar Skip to footer

Assign Value To Registered Hidden Field In Page Clientscript

I am using Page.ClientScript.RegisterHiddenField('hf_Name',value) in an ASP.net application, how to override or assign a new value to the same Hidden Field 'hf_Name' in code behind

Solution 1:

RegisterHiddenField doesn't create a server side control, it just creates a plain-old <input type="hidden" name="myhiddenField">

Page.FindControl("myhiddenField") will never find anything on serverside and even document.getElementById("myhiddenField") will return nothing on clientside since only the name and not the id is assigned.

So if you need to access it on serverside, you should use a HiddenField server control or at least use a html-inputtype=hidden with runat="server".

Post a Comment for "Assign Value To Registered Hidden Field In Page Clientscript"