sensible way to pass around values

D

David C

With .NET 1.x, this is what I did. On the destination page

public class ToWebForm : System.Web.UI.Page
{
public const string PARAMETER = "PARAM";
protected void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
string paramFromAnotherPage = Context.Items[PARAMETER].ToString();
Response.Write(paramFromAnotherPage);
}
}
}

And on the source page
Context.Items.Add(ToWebForm.PARAMETER, "value");
Server.Transfer("ToWebForm.aspx");

Basically I am creating an interface (not in a .net sense) on the
destination page so that the source page can simply use the string
constant as the name of the parameter.

..NET 2.0 does not seem to be happy with this. The funny thing is,
sometimes it works, and sometimes it does not even compile, which I
find very frustrating.

Is there any reason why this won't work well with partial classes?

And what is the sensible way to pass values from page to page without
having to copy and past the parameter names all over the web project?
 
R

Ross Culver

Is there anyway to enable this for a gridview? Perhaps a user control or a
hidden button?

Ross


Cowboy (Gregory A. Beamer) said:
.NET 2.0 is "last page aware". Try this:
http://msdn.microsoft.com/msdnmag/issues/05/10/ExtremeASPNET/

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com
Co-author: Microsoft Expression Web Bible (upcoming)

************************************************
Think outside the box!
************************************************
David C said:
With .NET 1.x, this is what I did. On the destination page

public class ToWebForm : System.Web.UI.Page
{
public const string PARAMETER = "PARAM";
protected void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
string paramFromAnotherPage = Context.Items[PARAMETER].ToString();
Response.Write(paramFromAnotherPage);
}
}
}

And on the source page
Context.Items.Add(ToWebForm.PARAMETER, "value");
Server.Transfer("ToWebForm.aspx");

Basically I am creating an interface (not in a .net sense) on the
destination page so that the source page can simply use the string
constant as the name of the parameter.

.NET 2.0 does not seem to be happy with this. The funny thing is,
sometimes it works, and sometimes it does not even compile, which I
find very frustrating.

Is there any reason why this won't work well with partial classes?

And what is the sensible way to pass values from page to page without
having to copy and past the parameter names all over the web project?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top