document.getElementById to Find Field in User Control that is Inside an UpdatePanel

F

Frank

I have been googling this for quite sometime and have been finding guidance
and samples that just don't work with my particular scenario.

I simply need for my JavaScript to be able to get a reference to an HTML
hidden field, where:
1. the hidden field exists in a user control that is dynamically added to a
PlaceHolder (in the code behind)
2. the PlaceHolder that hosts the user control exists within an AJAX
UpdatePanel.

I have received different bits of advice on this - but none apparently
account for *both* of the above facts.

I'd really appreciate guidance on how to declare the hidden field in the
user control (i.e., does it need runat=server?), and then how to obtain it's
current value in client-side JavaScript - given that the user control is
ultimately rendered within an UpdatePanel.

What's complicating things - at least for me - is that (1) the user control
is renaming the hidden field; and (2) the contents of an update panel are
apparently built by javascript.

Thanks
 
B

bruce barker

its depends on the use of the hidden control. if you need access to it
from the usercontrol then use a runat="server" and register clientscript
in the usercontrol to save the name:

ScriptManager.RegisterStartupScript(
this,
this.GetType(),
"hidden",
string.Format("var theHiddenFieldName = '{0}';",
myHiddenField.ClientID),
true);


-- bruce (sqlwork.com)
 
F

Frank

I need to access the hidden field from JavaScript (client-side).
Specifically, the JavaScript needs to find the current value of the hidden
field that is located within a user control that is in turn located within
an UpdatePanel.

How can I do that?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top