finding the form that owns the usercontrol

  • Thread starter Thread starter Karl Prosser
  • Start date Start date
K

Karl Prosser

i have various usercontrols that get dynamically into a page
my usercontrol has html Input fields,
and from javascript i need to access them, however to access them i
need to know the form..
currently the code i use to generate the javascript i do for example

....
document.forms[0]." + GRIDENTER.ClientID + @".value= 'YES';
....
(gridenter is a htmlinputtext )

which works, however what if there is more than one form in the host
page
surely there is a way i can get the clientID of the controls host
form.

Karl
 
I think I understand what you are asking, and you might be looking to
do more work than you need. ASP.NET generates the ClientID so it is
always unique.

If you are worrying about multiple forms appearing on an aspx page, be
aware that aspx pages allow only one server side form tag, so this
should not present a problem either.

This article goes into some more detail on both subjects:
Form-based Programming in ASP.NET
http://msdn.microsoft.com/msdnmag/issues/03/05/CuttingEdge/default.aspx

HTH,
 
Back
Top