Home All Groups Group Topic Archive Search About

Accessing server controls using client scripts....

Author
16 Dec 2005 9:59 AM
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

Author
16 Dec 2005 11:41 AM
David Jessee
Have you tried dynamicly generating your script, using the ClientId property
of the controls to get the ids for the hidden fields?

Show quoteHide quote
"Stu" wrote:

> 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
>
>
>
Are all your drivers up to date? click for free checkup

Author
16 Dec 2005 3:54 PM
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");

--
Daniel TIZON
MCP - MCSD.NET - MCT


"David Jessee" <DavidJes***@discussions.microsoft.com> a écrit dans le
message de news: 32A6E15E-B8CF-4C8A-89DC-F885CDA29***@microsoft.com...
Show quoteHide quote
> Have you tried dynamicly generating your script, using the ClientId
> property
> of the controls to get the ids for the hidden fields?
>
> "Stu" wrote:
>
>> 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
>>
>>
>>

Bookmark and Share