Home All Groups Group Topic Archive Search About
Author
7 Apr 2006 2:48 PM
Ben Schumacher
If I place a usercontrol .ascx on a webform .aspx, is there a way to access
the clientid propery of controls on the webform .aspx from within the
Page_Load of the .ascx.

For example, I have a webform with ...

<asp:textbox id="txtOne" runat="server">

and a usercontrol ...

<test:usercontrol id="testUserControl" runat="server">

Now, how can i access the clientid of txtOne from within the Page_Load event
of the UserControl?

Author
8 Apr 2006 7:27 AM
Teemu Keiski
Hi,

generally it is not good idea to access Page from the control because it
would make the control specific to that page.  Therefore more suitable would
be declaring property in the UC (representing the ClientID), which Page
could set in code.

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke


Show quoteHide quote
"Ben Schumacher" <bschumac***@navegate.com> wrote in message
news:OiMU0JlWGHA.924@TK2MSFTNGP03.phx.gbl...
> If I place a usercontrol .ascx on a webform .aspx, is there a way to
> access the clientid propery of controls on the webform .aspx from within
> the Page_Load of the .ascx.
>
> For example, I have a webform with ...
>
> <asp:textbox id="txtOne" runat="server">
>
> and a usercontrol ...
>
> <test:usercontrol id="testUserControl" runat="server">
>
> Now, how can i access the clientid of txtOne from within the Page_Load
> event of the UserControl?
>

Bookmark and Share