470,635 Members | 2,279 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,635 developers. It's quick & easy.

Passing Server Control Values Between Pages

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 =
Nov 15 '05 #1
1 2875
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" <jo***********@surfcontrol.com> wrote in message
news:uS**************@tk2msftngp13.phx.gbl...
"Matt M" <matt@remove_this_core49.com> wrote in message
news:Yc***********************@news3.calgary.shaw. 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
jo***********@surfcontrol.com

Nov 15 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Gordon Hudson | last post: by
6 posts views Thread by Newbie | last post: by
1 post views Thread by Matt M | last post: by
2 posts views Thread by Greg Decos | last post: by
4 posts views Thread by gkr | last post: by
1 post views Thread by olduncleamos | last post: by
1 post views Thread by Steve | last post: by
Vkas
4 posts views Thread by Vkas | last post: by
1 post views Thread by Korara | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.