Accessing server controls using client scripts....

S

Stu

Hi,

I am migrating a large app to .Net 2 and am having problems with accessing
hidden fields using javascript.

As I am using masterpages the control names are prefixed with the control
reference of the masterpage '_ctl0_cphMain_MyHiddenField' etc. The app uses
dynamically assigned masterpages to the control name on the page changes
depending on the masterpage being used. There is no

Is there any way of specifying a clientside name to a hidden field, or
adding the additional string to the script automatically?

Thanks in advance,
Stu
 
G

Guest

Have you tried dynamicly generating your script, using the ClientId property
of the controls to get the ids for the hidden fields?
 
D

Daniel TIZON

In ASP.NET 2.0, you shoud use the functions placed in Page.ClientScript to
register scripts or hidden fields in the page. In the previous version of
ASP.NET theses functions where placed directly on the Page object.
In your example, you can use the folowing statement to register your hidden
field from a UserControl, the Page or from the MasterPage. The client ID of
the field will be preserved with this method :)

Page.ClientScript.RegisterHiddenField("MyHiddenField", "default value");
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top