accessing aspx control from ascx

  • Thread starter Thread starter rom
  • Start date Start date
R

rom

Hi,

I have an aspx page with header as user control, footer as
user control, and 2 other user controls inside the page.

I'm trying to access a seleted value of a dropdownlist the
exists in the main aspx page from one of the user
controls. I know it's possible because I reached it by
using debug and it exists with the value in here:

directcast(page.controls(3).controls
(19),dropdownlist).selectedvalue

but, of course, this is not a way to solve things....
How can I do this correctly?

Thanks.
 
I'm trying to access a seleted value of a dropdownlist the
exists in the main aspx page from one of the user
controls. I know it's possible because I reached it by
using debug and it exists with the value in here:

You can access the controls on the page via the Page property of the
UserControl like this:
Control control=Page.FindControl("MyControl");

However, I suggest that you redesign your application because UserControls
should not depend on controls in it's container (Page in your example).

Anders Norås
blog: http://dotnetjunkies.com/weblog/anoras/
 
Back
Top