Ask a Question related to ASP.NET General, Design and Development.
-
Mark Friedman #1
Referencing subcontrols within UserControl
Does anyone know how to reference a subcontrol of a UserControl within
client-side script. For example, if I have a TextBox as one of the elements
of my UserControl with an id of "MyTextBox", how do I reference it within
some jscript function. If I try to just reference it as MyTextBox I get an
error saying that MyTextBox is undefined.
From looking at the generated source, I believe that there are two issues
involved. One is that the subcontrol's ID is getting renamed to something
like Foo1_MyTextBox, where Foo is the name of the UserControl. The second
issue is that the reference seems to need to be qualified by it's parent
form's ID, e.g. Form1.Foo1_MyTextBox. If I reference the TextBox that way
it works, but there are a couple of problems, First, I can't be sure what
the renaming be. I assume that if I have more than one instance of the
UserControl on a form that the prefix will change. The second problem is
that I don't know what the ID if the containing form is going to be so I
can't know how to qualify the TextBox's name.
Thanks in advance.
-Mark
Mark Friedman Guest
-
referencing and anchor from within a usercontrol (ascx)
Hi, I am trying to reference an anchor in a user control with a url. This worked in 1.1 but no longer works in 2.0. The ascx control is... -
Question about DataBindings in subcontrols
Hi. I'm developing a custom webcontrol that have a property derived from BaseCollection that realizes a collection of particular web controls. When... -
VS.NET not creating the Site for SubControls
I'm experiencing the same problem as was discussed in a thread with this subject "VS.NET not creating the Site for SubControls" I have a control... -
Referencing a panel on a webform from an usercontrol
My question is whether it's possible to change the properties of a panel, that resides on the webform containing the usercontrol, in the... -
Use LoadControl to load a usercontrol but the webcontrol in the usercontrol can not AutoPostBack
a uscontrol test.ascx have a dropdownlist web control the dropdownlist's AutoPostBack property is set "true" but when i use... -
James J. Foster #2
Re: Referencing subcontrols within UserControl
Use the ClientID property to get the name of the control in the resulting
HTML.
--
James J. Foster, DotNetCoders
[url]http://www.dotnetcoders.com[/url]
"Mark Friedman" <bingster@yahoo.com> wrote in message
news:%239p0nijRDHA.2676@TK2MSFTNGP10.phx.gbl...elements> Does anyone know how to reference a subcontrol of a UserControl within
> client-side script. For example, if I have a TextBox as one of thean> of my UserControl with an id of "MyTextBox", how do I reference it within
> some jscript function. If I try to just reference it as MyTextBox I get> error saying that MyTextBox is undefined.
>
> From looking at the generated source, I believe that there are two issues
> involved. One is that the subcontrol's ID is getting renamed to something
> like Foo1_MyTextBox, where Foo is the name of the UserControl. The second
> issue is that the reference seems to need to be qualified by it's parent
> form's ID, e.g. Form1.Foo1_MyTextBox. If I reference the TextBox that way
> it works, but there are a couple of problems, First, I can't be sure what
> the renaming be. I assume that if I have more than one instance of the
> UserControl on a form that the prefix will change. The second problem is
> that I don't know what the ID if the containing form is going to be so I
> can't know how to qualify the TextBox's name.
>
> Thanks in advance.
>
> -Mark
>
>
James J. Foster Guest
-
Mark Friedman #3
Re: Referencing subcontrols within UserControl
I take your response to refer to client-side script that would be generated
by my UserControl, but what I'd really like to do is just write the script
code directly in the page. Is there a way to do what I want without
generating the script in the control?
-Mark
"James J. Foster" <james@dotnetcoders.com> wrote in message
news:ucvrgxjRDHA.3796@tk2msftngp13.phx.gbl...within> Use the ClientID property to get the name of the control in the resulting
> HTML.
>
> --
> James J. Foster, DotNetCoders
> [url]http://www.dotnetcoders.com[/url]
>
>
> "Mark Friedman" <bingster@yahoo.com> wrote in message
> news:%239p0nijRDHA.2676@TK2MSFTNGP10.phx.gbl...> elements> > Does anyone know how to reference a subcontrol of a UserControl within
> > client-side script. For example, if I have a TextBox as one of the> > of my UserControl with an id of "MyTextBox", how do I reference itissues> an> > some jscript function. If I try to just reference it as MyTextBox I get> > error saying that MyTextBox is undefined.
> >
> > From looking at the generated source, I believe that there are twosomething> > involved. One is that the subcontrol's ID is getting renamed tosecond> > like Foo1_MyTextBox, where Foo is the name of the UserControl. Theway> > issue is that the reference seems to need to be qualified by it's parent
> > form's ID, e.g. Form1.Foo1_MyTextBox. If I reference the TextBox thatwhat> > it works, but there are a couple of problems, First, I can't be sureis> > the renaming be. I assume that if I have more than one instance of the
> > UserControl on a form that the prefix will change. The second problem>> > that I don't know what the ID if the containing form is going to be so I
> > can't know how to qualify the TextBox's name.
> >
> > Thanks in advance.
> >
> > -Mark
> >
> >
>
Mark Friedman Guest
-
bruce barker #4
Re: Referencing subcontrols within UserControl
<script>
var ctl = document.getElementById('<% =
FindControl("myusercontrol").FindControl("mysubcon trol").ClientId %>');
</script>
"Mark Friedman" <bingster@yahoo.com> wrote in message
news:uyS7$ikRDHA.632@TK2MSFTNGP12.phx.gbl...generated> I take your response to refer to client-side script that would beresulting> by my UserControl, but what I'd really like to do is just write the script
> code directly in the page. Is there a way to do what I want without
> generating the script in the control?
>
> -Mark
>
> "James J. Foster" <james@dotnetcoders.com> wrote in message
> news:ucvrgxjRDHA.3796@tk2msftngp13.phx.gbl...> > Use the ClientID property to get the name of the control in theget> within> > HTML.
> >
> > --
> > James J. Foster, DotNetCoders
> > [url]http://www.dotnetcoders.com[/url]
> >
> >
> > "Mark Friedman" <bingster@yahoo.com> wrote in message
> > news:%239p0nijRDHA.2676@TK2MSFTNGP10.phx.gbl...> > elements> > > Does anyone know how to reference a subcontrol of a UserControl within
> > > client-side script. For example, if I have a TextBox as one of the> > > of my UserControl with an id of "MyTextBox", how do I reference it> > > some jscript function. If I try to just reference it as MyTextBox Iparent> issues> > an> > > error saying that MyTextBox is undefined.
> > >
> > > From looking at the generated source, I believe that there are two> something> > > involved. One is that the subcontrol's ID is getting renamed to> second> > > like Foo1_MyTextBox, where Foo is the name of the UserControl. The> > > issue is that the reference seems to need to be qualified by it'sI> way> > > form's ID, e.g. Form1.Foo1_MyTextBox. If I reference the TextBox that> what> > > it works, but there are a couple of problems, First, I can't be sure> is> > > the renaming be. I assume that if I have more than one instance of the
> > > UserControl on a form that the prefix will change. The second problem> > > that I don't know what the ID if the containing form is going to be so>> >> > > can't know how to qualify the TextBox's name.
> > >
> > > Thanks in advance.
> > >
> > > -Mark
> > >
> > >
> >
>
bruce barker Guest
-
Christopher Young #5
Re: Referencing subcontrols within UserControl
Thank you very much.
*** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
Don't just participate in USENET...get rewarded for it!
Christopher Young Guest



Reply With Quote

