Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > accessing aspx control from ascx

Reply
Thread Tools

accessing aspx control from ascx

 
 
rom
Guest
Posts: n/a
 
      11-22-2004
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.
 
Reply With Quote
 
 
 
 
Anders Norås
Guest
Posts: n/a
 
      11-22-2004
> 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/


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
accessing .ascx data from .aspx Martin Eyles ASP .Net 6 01-19-2006 11:14 AM
accessing aspx object from ascx pages and vise verce? rom ASP .Net Building Controls 3 11-23-2004 01:31 AM
Multiple *.ascx files with a single *.ascx.cs in VS.NET 2003 Holger (David) Wagner ASP .Net 2 07-03-2004 09:23 AM
can a dg be added to an ascx? ascx call a ws? Jason Shohet ASP .Net 1 11-10-2003 07:08 PM
[ASCX] Add an ascx in a webcontrol... Quentin ASP .Net 1 07-29-2003 07:37 PM



Advertisments