Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
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
 
Old May 9th, 2005, 06:44 AM
vbmazza
Guest
 
Posts: n/a
Default Passing Values using ASP.NET in VB

Hi,

I have two aspx pages in an ASP.NET project within visual studio. I take some values on a
web form, when a submit button is clicked, changes are made to my SQL database.

I need to pass certain values from one page to another for example

strModuleName - Holds the name of a report
intModuleID - Holds the ID Value for that report

The two pages I have are ReportCreator.aspx and Report.aspx, I want to pass the value contained in the string and integer above so I can use the current value of those variables in the Report Form.

Can anyone tell me a way to pass these values to the 2nd page, I am using VB to program this application.

Many Thanks:)

VBMazza
 
Old May 9th, 2005, 09:19 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You could either put the values into session:

Session("moduleName") = strModuleName
Session("moduleID") = intModuleID

then get them out on the report page the other way around. You'll need to convert their type (at least for the ID) because session values are always objects.

strModuleName = Session("moduleName").ToString
intModuleID = CType(Session("moduleID"), Integer)

Alternatively you could put the values on the querystring when you redirect to that page:

Response.Redirect(String.Format("Report.aspx?modul eName={0}&moduleID={1}", strModuleName, intModuleID)

-Peter
 
Old May 9th, 2005, 09:31 AM
vbmazza
Guest
 
Posts: n/a
Default

Thanks Peter.

How do I receive the values at the other end?

For example I may use a label - label1 lets say, and I use something like:

Label1.Text = strModuleName

or something similar to show the name value in the new report. Let say I have used
the Response Redirect method, how can I re-use the values at the other end?

As you can probably tell, this is new to me, so any help you can give would be excellent.

Thanks





VBMazza
 
Old May 9th, 2005, 09:34 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Sorry, forgot the rest of the querystring sample:

Response.Redirect(String.Format("Report.aspx?modul eName={0}&moduleID={1}", strModuleName, intModuleID)

Report.aspx:
strModuleName = Request.QueryString(moduleName")
intModuleID = CType(Request.QueryString("moduleID"), Integer)

-Peter
 
Old May 9th, 2005, 09:43 AM
vbmazza
Guest
 
Posts: n/a
Default

Thanks again. Sorry to be a further pain, but:

I have used the respose.redirect on the ReportCreator form and then used the query strings you sent in the last message. I managed to put those in OK, but I get a squiggly line under strModuleName and intModuleID in the Report form code saying that the variables are not declared, do I need anything else for it to recognise those variables.

Like inherits, or something similar?

VBMazza
 
Old May 9th, 2005, 01:02 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You need a Dim statement, just like for the other variables. Look like I missed a quote on the first line for the moduleName quertystring key:

Report.aspx:
Dim strModuleName As String
Dim intModuleID As Integer
strModuleName = Request.QueryString("moduleName")
intModuleID = CType(Request.QueryString("moduleID"), Integer)

-Peter
 
Old May 9th, 2005, 03:29 PM
vbmazza
Guest
 
Posts: n/a
Default

Thanks for that, I should have realised to dim the variables, I was initially thrown thinking the values were passed using the same names rather than the ones you had supplemented them for.

I stopped pulling my hair out now.:D

VBMazza





Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing values from asp to a javascript Abhilash Classic ASP Basics 11 June 15th, 2011 12:38 PM
Passing Form Values in ASP.Net sankar General .NET 10 September 21st, 2006 11:13 AM
Passing values between Asp to Aspx page jayaraj General .NET 2 May 25th, 2004 01:16 AM
Passing values between Asp to Asp pages. jayaraj ASP.NET 1.0 and 1.1 Professional 3 May 23rd, 2004 06:53 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.