|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Accessing server controls using client scripts....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 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 > > > 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 >> >> >>
Other interesting topics
Server.Execute & HttpHandler
hides inherited member ApplicationInstance ObjectDataSource won't perform updates One application... multiple domains Custom memebrship provider problem Can I have a global.asax just for an application? The type '_Default' conflicts with the imported type '_Default' Wierdness with "Imports" statement ObjectDataSource - Object Graphs Problem connecting to SQL Server 2000 using VS 2005 (Please help!) |
|||||||||||||||||||||||