473,385 Members | 1,409 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,385 software developers and data experts.

Retrieving variables from querystring

Kim
In ASP.NET 2.0, I'm using "Response.Redirect" method to pass a variable in a
URL from one page to another as such:

Protected Sub btnSubmit_Click(ByVal s as System.Object, ByVal e as
System.EventArgs) Handles btnSubmit.Click
Response.Redirect("Default2.aspx?name= " &

System.Web.HttpUtlity.URLEncode(txtName.text))
End Sub

Public ReadOnly Property TargetName( ) As String
Get
return System.Web.HttpUtility.URLDecode(txtName.Text)
End Get
End Property
______________________________________________

In Default2.aspx page, I've added an <%@ PreviousPageType
VirtualPath='~/Default.aspx' %> directive to point to the previous page.

In the "Page_Load" method, the following code was added:

Protected Sub Page_Load(ByVal s as System.Object, ByVal e as
System.EventArgs) Handles Me.Load
Dim strName As String = PreviousPage.targetName
lblGreeting.Text = "Hello " & strName & "Welcome to ASP.NET"
End Sub
__________________________________________________ _______
A "System.NullReferenceException: Object not set to an instance of an
object" error was thrown.
How could the "targetName" value be retrieved for displayed in the label ?
Jul 1 '06 #1
1 1025
Request.QueryString will have everything you want. No need to fiddle
with PreviousPage or anything.
Jason Kester
Expat Software Consulting Services
http://www.expatsoftware.com/

---
Get your own Travel Blog, with itinerary maps and photos!
http://www.blogabond.com/

Jul 1 '06 #2

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

Similar topics

4
by: JA | last post by:
I have this little tell-a-friend script that will send out a link back to the site. I want to put a link on my product pages that will go to the script, and have the script display the product...
1
by: Consuelo Guenther | last post by:
Hello, I am having problems with passing variables between pages. I have the following: First asp page has the function: -----------------------------------------------------------------------...
3
by: Earl Teigrob | last post by:
I have a small application that consists of one aspx page with inline and dynamically loaded user and custom controls. When the page loads, I need to calculate a set of global SESSION variables...
1
by: Bill Patel | last post by:
Variable ta, tb, tc, td and te are not updated in the SUB WriteTableDetail. As a result, Response write of the ta, tb, tc td and te displays 0. Sub Page_load(Src AS Object, e AS EventArgs) IF...
7
by: Sirplaya | last post by:
I am retrieving images that I stored in SQL Server on my web pages in C#. I have no problem with the images displaying, however, I am trying to wrap the image with an <A HREF ..." and each time I...
3
by: mike | last post by:
Hello, I've got a .aspx page that passes login information to an .asp page using a querystring. The problem is its not secure, the user can see the login information right there and type in...
3
by: BOBss | last post by:
I have an .ASP page that comes up, and I am trying retrieve a variable from the previous .ASP page. However none of the variables from the previous .ASP page are available to the current .ASP page....
12
by: MrHelpMe | last post by:
Hello again all, I've finished my whole application and now I don't like the whole session variables that I am using. I have a form, user fills in info clicks submit and using CDOSYSMail an...
0
by: bharathreddy | last post by:
Here I will given an example on how to access the session, application and querystring variables in an .cs class file. Using System.Web.HttpContext class. 1) For accesing session variables :...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.