How to determine calling page

  • Thread starter Thread starter NewsMonkey
  • Start date Start date
N

NewsMonkey

Hi Everyone,

I am using "Server.Transfer()" to send data to an ASP.NET page that's
sole purpose is to display messages. I am using "Server.Transfer since I
can set the contents of the message I want to display via the properties
of the page that is initiating the Server.Transfer() and also because
large amounts of data can be sent, such as a datagrid or other object.
Here is an example...

/* Sending Page (GenerateMessage.aspx) */

private string mMsg1 = "This is the first message";
private string mMsg2 = "This is the second message";

public string Message1
{
Get {return mMsg1;}
}

public string Message2
{
Get {return mMsg2;}
}

Server.Transfer("DisplayMessages.aspx");


/* Receiving Page (DisplayMessages.aspx) */

GenerateMessage objPage = (GenerateMessage)Context.Handler;
Response.Write("<B>" + objPage.Message1 + "</B>");
Response.Write("<B>" + objPage.Message2 + "</B>");


The question I am having is how can the "receiving page", in this case
"DisplayMessages.aspx", determine what the class of the sending page is
during runtime? I would like to be able to have the
"DisplayMessages.aspx" page accept messages from many different pages
but since I need to cast the Context.Handler object to the class of the
sending page it would seem that I would need to know the class name
ahead of time. Any suggestions? Thanks!

- DerekTheGeek
 
One way is to use httpcontext to pass the url of the caller, e.g. (vb syntax

On GenerateMessage.asp
context.Items.Add("URI", Page.Request.Url
Server.Transfer("DisplayMessages.aspx"

Then on the called page..
Dim Caller As Uri = CType(context.Items("URI"), Uri

But, in this case, I'm not sure what that buys you, probably because I don't understand how your generic messages page is going to take different objects like datasets, strings, etc. and know how to display them all as messages. Anyway, I don't know the syntax and haven't done much with it, but if you are setting preserveForm=true on the calling page, can't you then do request.form on the receiving page to get the collection of form variables from the caller

Bil

----- NewsMonkey wrote: ----

Hi Everyone

I am using "Server.Transfer()" to send data to an ASP.NET page that's
sole purpose is to display messages. I am using "Server.Transfer since I
can set the contents of the message I want to display via the properties
of the page that is initiating the Server.Transfer() and also because
large amounts of data can be sent, such as a datagrid or other object.
Here is an example..

/* Sending Page (GenerateMessage.aspx) *

private string mMsg1 = "This is the first message"
private string mMsg2 = "This is the second message"

public string Message

Get {return mMsg1;


public string Message

Get {return mMsg2;


Server.Transfer("DisplayMessages.aspx")


/* Receiving Page (DisplayMessages.aspx) *

GenerateMessage objPage = (GenerateMessage)Context.Handler
Response.Write("<B>" + objPage.Message1 + "</B>")
Response.Write("<B>" + objPage.Message2 + "</B>")


The question I am having is how can the "receiving page", in this case
"DisplayMessages.aspx", determine what the class of the sending page is
during runtime? I would like to be able to have the
"DisplayMessages.aspx" page accept messages from many different pages
but since I need to cast the Context.Handler object to the class of the
sending page it would seem that I would need to know the class name
ahead of time. Any suggestions? Thanks

- DerekTheGee
 
Back
Top