473,404 Members | 2,195 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

sensible way to pass around values

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?

Aug 6 '07 #1
3 1274
..NET 2.0 is "last page aware". Try this:
http://msdn.microsoft.com/msdnmag/is...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" <pr********@gmail.comwrote in message
news:11********************@z24g2000prh.googlegrou ps.com...
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?

Aug 7 '07 #2
On Aug 7, 6:20 am, "Cowboy \(Gregory A. Beamer\)"
<NoSpamMgbwo...@comcast.netNoSpamMwrote:
.NET 2.0 is "last page aware". Try this:http://msdn.microsoft.com/msdnmag/is...ExtremeASPNET/

Thank you very much. I was pleasantly surprised to see that it even
reads the ViewState of the previous page.

Aug 7 '07 #3
Is there anyway to enable this for a gridview? Perhaps a user control or a
hidden button?

Ross
"Cowboy (Gregory A. Beamer)" <No************@comcast.netNoSpamMwrote in
message news:%2****************@TK2MSFTNGP05.phx.gbl...
.NET 2.0 is "last page aware". Try this:
http://msdn.microsoft.com/msdnmag/is...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" <pr********@gmail.comwrote in message
news:11********************@z24g2000prh.googlegrou ps.com...
>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?


Aug 7 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: timothy.williams | last post by:
Hi. I trying to write an extension module to call some C libraries so I can use them in Python. Several of the library functions pass pointers to structures as arguments. I was thinking that I...
7
by: Andy Fish | last post by:
Hi, I have a javascript solution where page A launches page B in a second window and then they can pass data between them. That's all well and good. Now say page B wants to navigate to page C...
2
by: Martin McCormick | last post by:
Most of the C programming I write manipulates strings so I haven't had much experience with numerical functions and passing variables in and out which brings me to a laughably simple problem that I...
3
by: Hermit Dave | last post by:
Hi, Trying to pass a value to user control within a page. 1. Couldnt find a way to pass it from code behind file. 2. Trying to pass it from aspx page... using EditURL='<% "mypage.aspx?myvar=" +...
1
by: samir dsf | last post by:
hi i can send and retrieve a single value. but now i have around 3-4 values which i want to pass, from a link and receive in another page. here is how i am currently doing: Dim urlParams As...
14
by: Derek Basch | last post by:
This one has always bugged me. Is it better to just slap a "self" in front of any variable that will be used by more than one class method or should I pass around variable between the methods? ...
6
by: kath | last post by:
hi everyone......... I have a task, I have fragmented the task into subtask. I have planned to create a class to each subclass and one parent class to handle the sub tasks. Each subclass are...
13
by: magickarle | last post by:
Hi, I got a pass-through query (that takes about 15 mins to process) I would like to integrate variables to it. IE: something simple: Select EmplID from empl_Lst where empl_lst.timestamp between...
12
by: raylopez99 | last post by:
Keywords: scope resolution, passing classes between parent and child forms, parameter constructor method, normal constructor, default constructor, forward reference, sharing classes between forms....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.