 |
| ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

August 12th, 2004, 10:52 AM
|
|
Friend of Wrox
|
|
Join Date: Oct 2003
Posts: 218
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Passing Values
I can't believe I'm asking this, but...
Up until this point in my ASP.NET travels, I have only had to pass simple values from one page to another. Most of the time I have used the querystring to pass an ID value - rarely, I use a Session variable.
Before .NET, I would pass the values via form variables; hidden inputs and the like.
How do I accomplish this function without resorting to using the Session?
- - - - - - - - - - - - - - - - - - - - - - -
In God we trust, everything else we test.
|
|

August 12th, 2004, 11:29 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
|
|
If you are transferring to a different page, how about using "Server.Transfer("page_to_go_to.aspx", True)"?
I believe you can access the original's form data by setting the second argument(preserveForm) to true.
I believe you will have to also set the EnableViewStateMac attribute of the Page directive to false on the destination page. Otherwise, it will think that the ViewState of the new page has been tampered with.
J
|
|

August 12th, 2004, 01:22 PM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
Colonel,
You can pass additional values on the querystring after the first with the &...
.aspx?id=1234&another=3423&yetanother=hello
They'll all end up in the Request.QueryString collection.
If you need the values to be hidden, I'd recommend the session. Because you can't (yet) have a form post to another page, it's not very easy to deal with hidden form values and the like. Plus, you then have to deal with manual extraction of the values from the Request.Form collection, and because of .NET's naming methods, the form element names could change.
|
|

August 13th, 2004, 07:24 AM
|
|
Friend of Wrox
|
|
Join Date: Oct 2003
Posts: 218
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Yeah, I'm familiar with appending querystring values with &, but I need to avoid it in this case. In general, I like to keep the querystring pretty clean if I can.
Well it appears my best option is to set Session variables, use them and then remove them.
Thanks for your comments as always!
- - - - - - - - - - - - - - - - - - - - - - -
In God we trust, everything else we test.
|
|

August 13th, 2004, 09:14 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,101
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
Is there a reason you are avoiding the session in this case? .NET sessions work much better than ASP sessions.
Hal Levy
Web Developer, PDI Inc.
NOT a Wiley/Wrox Employee
|
|

August 13th, 2004, 09:28 AM
|
|
Friend of Wrox
|
|
Join Date: Oct 2003
Posts: 218
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
You bring up a good point, Hal. The reason I would have avoided sessions before .NET was to preserve resources. I am not familiar with the difference in how .NET handles sessions. How is the use of sessions improved?
- - - - - - - - - - - - - - - - - - - - - - -
In God we trust, everything else we test.
|
|

August 13th, 2004, 09:39 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
|
|
While I agree that it isn't the best way to do it, I just very easily extracted a hidden value from one page to another using the method I described above.
Add a hidden field to your first page, right-click on it and click "Run As Server Control". .Net will automatically give it an ID and Name.
You should then be able to access this value from the second page.
It isn't pretty and I wouldn't do it unless I absolutely had to, but...
J
|
|

August 13th, 2004, 10:08 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,101
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
.NET, while still consuming memory resources, have made some great improvements on the session in that it can be stored to a DB, you can use cookieless sessions .. and more.. I'd suggest you read about them before you discount them.
http://www.411asp.net/home/tutorial/...c/web/sessions has a number of links to articles on the topic.
Hal Levy
Web Developer, PDI Inc.
NOT a Wiley/Wrox Employee
|
|

August 13th, 2004, 10:29 AM
|
|
Friend of Wrox
|
|
Join Date: Oct 2003
Posts: 218
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks!
- - - - - - - - - - - - - - - - - - - - - - -
In God we trust, everything else we test.
|
|
 |