Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > accessing aspx object from ascx pages and vise verce?

Reply
Thread Tools

accessing aspx object from ascx pages and vise verce?

 
 
rom
Guest
Posts: n/a
 
      11-22-2004
Is there a better way of doing it, except from using the
session variables?

Thanks!
 
Reply With Quote
 
 
 
 
John Saunders
Guest
Posts: n/a
 
      11-22-2004
"rom" <(E-Mail Removed)> wrote in message
news:7b2901c4d073$6fca4580$(E-Mail Removed)...
> Is there a better way of doing it, except from using the
> session variables?


Depends on what you're asking. What sort of "object" are you referring to?

Keep in mind that both the page and user control are objects of classes. You
can add public properties and events to each. For instance, this allows the
page to pass information to a user control and to subscribe to any events
the user control raises.

John Saunders


 
Reply With Quote
 
 
 
 
rom
Guest
Posts: n/a
 
      11-22-2004
Thanks for the quick response. I'm asking, for example,
about reading the selectedvalue of a dropdownlist that
exists in the aspx page from it's ascx page....

Thanks!

>-----Original Message-----
>"rom" <(E-Mail Removed)> wrote in message
>news:7b2901c4d073$6fca4580$(E-Mail Removed)...
>> Is there a better way of doing it, except from using the
>> session variables?

>
>Depends on what you're asking. What sort of "object" are

you referring to?
>
>Keep in mind that both the page and user control are

objects of classes. You
>can add public properties and events to each. For

instance, this allows the
>page to pass information to a user control and to

subscribe to any events
>the user control raises.
>
>John Saunders
>
>
>.
>

 
Reply With Quote
 
John Saunders
Guest
Posts: n/a
 
      11-23-2004
"rom" <(E-Mail Removed)> wrote in message
news:8f9201c4d092$3bf19ff0$(E-Mail Removed)...
> Thanks for the quick response. I'm asking, for example,
> about reading the selectedvalue of a dropdownlist that
> exists in the aspx page from it's ascx page....


Again, you're talking objects now.

How would you handle this if there were some integer inside of object A
wihch you wanted to be able to access from object B? With a property!

However, your user controls are inside of your page. The usual way to handle
this sort of thing is for the container to set the properties of the
contained objects, and not the other way around. For instance, you could add
a ListSelectedIndex property to your user control, and your page could set
it in Page_Load or in the DataBinding event of the user control. If the user
control wanted to be able to change the SelectedIndex, it should expose a
public event. The page could listen for that event and set the SelectedIndex
accordingly. The event arguments would have to pass the new index.

Note how this isolates the page and the control from each other. The page
doesn't have to know _why_ the user control wants the SelectedIndex changed,
and the user control doesn't know anything at all about the DropDownList.
You could even change it to use a different control, and the user control
wouldn't care at all.


John Saunders


 
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
Anybody using Vise - good or bad? Martin @nohere.net Computer Support 4 09-15-2007 08:47 PM
passing variables from .aspx.cs code pages to .aspx pages RadioSignal ASP .Net Web Controls 7 10-21-2005 11:41 PM
share common methods and properties for .ASPX and .ASCX Pages Garth17 ASP .Net 3 03-18-2005 12:17 AM
___ad vise abowt reer end gangle7 Computer Support 5 12-31-2004 08:22 PM
find ASPX and ASCX pages in a web project.. Milsnips ASP .Net 4 11-19-2004 09:01 AM



Advertisments