Referencing a subcontrol of a UserControl within client-side script.

M

Mark Friedman

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
 

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,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top