Ask a Question related to ASP.NET General, Design and Development.
-
John #1
Referencing a control in Javascript
Hi all,
In my code-behind, I validate some controls and if a particular control has
a problem, I not only send an alert down to the client via
Page.RegisterStartupScript but I'd like to set the focus of the control. now
the control in question is embedded into a user control which is, in turn,
embedded into a user control which, in turn, is embedded onto a web form.
The Javascript does not work if I when I refernce the control with it's ID.
I checked the client source and saw it was renamed to
'_ctl2_UCIngDetail_lstUnits2'. Now when I changed the Javascript to
'document.frmMain._ctl2_UCIngDetail_lstUnits2.focu s();', this worked. but
isn't this going to break if controls are added to the usercontrol?
What is the correct way to solve this dilemma?
Regards
John.
John Guest
-
Referencing a parent control from a child?
I have two UserControls I'd like to have talk to each other. One of them is contained within the other, in a parent/child relationship. The child... -
output text in control location; calling control javascript from page javascript
Hi; If you don't know, I'm just learning javascript and aspnet, but I have a pretty good grounding in windows programming. I'm trying to build a... -
javascript: a method for referencing model by nam
this is kind of bassackwards, but it will work. i aint found a way to reference a model directly by name (yet), and since a model's index number is... -
Referencing Control Operators
Greetings. Is it possible to reference a control operator? For example, I'd like to take this code: sub getFieldFromAllRecords { my... -
Referencing a TextBox control in Javascript from DataList ItemTemplate
I have a calendar control which pops up as a new window when i click on my textbox. The calendar control returns a Javascript function whereby... -
PJ Lee #2
Re: Referencing a control in Javascript
You will need to use the "ClientID" property of the control to reference it
properly.
"John" <a@b.com> wrote in message
news:#U#wyG2QDHA.2592@TK2MSFTNGP10.phx.gbl...has> Hi all,
>
> In my code-behind, I validate some controls and if a particular controlnow> a problem, I not only send an alert down to the client via
> Page.RegisterStartupScript but I'd like to set the focus of the control.ID.> the control in question is embedded into a user control which is, in turn,
> embedded into a user control which, in turn, is embedded onto a web form.
>
> The Javascript does not work if I when I refernce the control with it's> I checked the client source and saw it was renamed to
> '_ctl2_UCIngDetail_lstUnits2'. Now when I changed the Javascript to
> 'document.frmMain._ctl2_UCIngDetail_lstUnits2.focu s();', this worked. but
> isn't this going to break if controls are added to the usercontrol?
>
> What is the correct way to solve this dilemma?
>
> Regards
> John.
>
>
PJ Lee Guest
-
David Waz... #3
Re: Referencing a control in Javascript
js ="<script ...>" & txtBox.ClientID & ".focus();</scirpt>"
"John" <a@b.com> wrote in message
news:#U#wyG2QDHA.2592@TK2MSFTNGP10.phx.gbl...has> Hi all,
>
> In my code-behind, I validate some controls and if a particular controlnow> a problem, I not only send an alert down to the client via
> Page.RegisterStartupScript but I'd like to set the focus of the control.ID.> the control in question is embedded into a user control which is, in turn,
> embedded into a user control which, in turn, is embedded onto a web form.
>
> The Javascript does not work if I when I refernce the control with it's> I checked the client source and saw it was renamed to
> '_ctl2_UCIngDetail_lstUnits2'. Now when I changed the Javascript to
> 'document.frmMain._ctl2_UCIngDetail_lstUnits2.focu s();', this worked. but
> isn't this going to break if controls are added to the usercontrol?
>
> What is the correct way to solve this dilemma?
>
> Regards
> John.
>
>
David Waz... Guest



Reply With Quote

