Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Passing Server Control Values Between Pages

Reply
Thread Tools

Passing Server Control Values Between Pages

 
 
Matt M
Guest
Posts: n/a
 
      08-28-2003
Ok. So I'm passing values between web pages, as per microsoft's framework
development guide
(http://msdn.microsoft.com/library/de...-us/cpguide/ht
ml/cpconPassingServerControlValuesBetweenPages.asp)

So, I have two pages, one that has some public properties and fires a
Server.Transfer("receivepage.aspx");

The receivepage.aspx can then get some of the public properties I've set on
the first page.

What I really want to be able to do is call the receivepage.aspx from a
variety of other pages. I am confused a little, because in the receivepage
you have to reference the sending page

i.e.

public sendingpage callPage;

private void Page_Load(object sender, System.EventArgs e)

{


if (!IsPostBack)

{

callPage = (sendingpage) Context.Handler;

}

How can I dynamically choose which page I want to reference? Is it
possible? Thanks for any help.

= matt =


 
Reply With Quote
 
 
 
 
Matt M
Guest
Posts: n/a
 
      08-28-2003
Perfect. Thank you very much. I'm a little new to .NET and C# for that
matter, so I will do your first option. I'm not too clear on the "deriving
from a base class" part.

Thanks.

- matt -

"John Saunders" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "Matt M" <matt@remove_this_core49.com> wrote in message
> news:Ycc3b.861167$(E-Mail Removed). ca...
> > Ok. So I'm passing values between web pages, as per microsoft's

framework
> > development guide
> >

>

(http://msdn.microsoft.com/library/de...-us/cpguide/ht
> > ml/cpconPassingServerControlValuesBetweenPages.asp)
> >
> > So, I have two pages, one that has some public properties and fires a
> > Server.Transfer("receivepage.aspx");
> >
> > The receivepage.aspx can then get some of the public properties I've set

> on
> > the first page.
> >
> > What I really want to be able to do is call the receivepage.aspx from a
> > variety of other pages. I am confused a little, because in the

> receivepage
> > you have to reference the sending page
> >

> ...
>
> > How can I dynamically choose which page I want to reference? Is it
> > possible? Thanks for any help.

>
> Matt, I may be misunderstanding your question, and if so, please forgive

me.
>
> The receiver page naturally cannot choose which page transferred to it.
> However, it can determine which page transferred to it:
>
> if (Context.Handler is PageType1)
> {
> PageType1 pt1 = (PageType1) Context.Handler;
> // Reference pt1.Property
> } else if (Context.Handler is PageType2)
> {
> PageType2 pt2 = (PageType2) Context.Handler;
> // Reference pt2.Property
> }
> else
> {
> throw new Exception("I don't know what kind of page called me!");
> }
>
> You say you want to call the receiver from multiple pages. Do all the
> "sending" pages have the same set of properties? If that's the case, you
> might want to create a base page class which contains all of those
> properties and then have the sending pages all derive from it. Your code

in
> the receiving page would then be much simpler:
>
> if (Context.Handler is BaseSendingPage)
> {
> BaseSendingPage bsp = (BaseSendingPage) Context.Handler;
> // Reference bsp .Property
> }
> else
> {
> throw new Exception("I don't know what kind of page called me!");
> }
> --
> John Saunders
> Internet Engineer
> http://www.velocityreviews.com/forums/(E-Mail Removed)
>
>



 
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
Passing values between web pages which are in different Web Sites Shankar Ayyachamy ASP .Net 4 01-28-2005 03:32 PM
Passing values between pages John ASP .Net 5 10-08-2004 09:24 PM
Context.Items vs Context.Handler (passing values between pages) VS_NET_DEV ASP .Net 2 05-25-2004 01:16 PM
Passing server control values between pages Greg Decos ASP .Net 2 04-15-2004 03:17 AM
Passing Values Between Web Forms Pages cgia ASP .Net 5 07-26-2003 06:20 AM



Advertisments