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

Passing and using parameters

Passing and using parameters

How to get hold of the parameter value provided by the URL? When I open a
web form with a DataSource I often include a parameter in the URL as below:

myNewPage.aspx?myParam = 10

If I simply need to use the value of myParam in the VB code when the new
page load, how do I refer to the parameter?

e.g. myLabel.Text = myParam (where myParam is replaced with a proper way to
refer to it)

TIRislaa
Dec 14 '06 #1
3 1529
It comes from the Request.QueryString collection. I forget the VB code, but
in C# it's:

Request.QueryString["myParam"].ToString()

Keep in mind, before you ever attempt to reference it, you'll need to make
sure that it is not a null value. If you don't test for null first, and the
querystring variable isn't present (it could be there but misspelled for
example) then it will through a null reference error when you attempt to use
the ToString() method on it. Always test for null first just in case.

in C# the test woud be:

if(Request.QueryString["myParam"] != null)
--

Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006
--

Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006

"Tor Inge Rislaa" <to************@rislaa.nowrote in message
news:uB**************@TK2MSFTNGP06.phx.gbl...
Passing and using parameters

How to get hold of the parameter value provided by the URL? When I open a
web form with a DataSource I often include a parameter in the URL as
below:

myNewPage.aspx?myParam = 10

If I simply need to use the value of myParam in the VB code when the new
page load, how do I refer to the parameter?

e.g. myLabel.Text = myParam (where myParam is replaced with a proper way
to refer to it)

TIRislaa


Dec 14 '06 #2
myLabel.Text = Request.QueryString("myParam")

or

Request.QueryString.GetValues("myParam")[1] if you have more than one named
myParam value

--
Regards

John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com
http://www.johntimney.com/blog
"Tor Inge Rislaa" <to************@rislaa.nowrote in message
news:uB**************@TK2MSFTNGP06.phx.gbl...
Passing and using parameters

How to get hold of the parameter value provided by the URL? When I open a
web form with a DataSource I often include a parameter in the URL as
below:

myNewPage.aspx?myParam = 10

If I simply need to use the value of myParam in the VB code when the new
page load, how do I refer to the parameter?

e.g. myLabel.Text = myParam (where myParam is replaced with a proper way
to refer to it)

TIRislaa


Dec 14 '06 #3
Solved my problem.
Thank you very much!

TIRislaa

"Mark Fitzpatrick" <ma******@fitzme.comskrev i melding
news:eH**************@TK2MSFTNGP04.phx.gbl...
It comes from the Request.QueryString collection. I forget the VB code,
but in C# it's:

Request.QueryString["myParam"].ToString()

Keep in mind, before you ever attempt to reference it, you'll need to make
sure that it is not a null value. If you don't test for null first, and
the querystring variable isn't present (it could be there but misspelled
for example) then it will through a null reference error when you attempt
to use the ToString() method on it. Always test for null first just in
case.

in C# the test woud be:

if(Request.QueryString["myParam"] != null)
--

Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006
--

Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006

"Tor Inge Rislaa" <to************@rislaa.nowrote in message
news:uB**************@TK2MSFTNGP06.phx.gbl...
>Passing and using parameters

How to get hold of the parameter value provided by the URL? When I open a
web form with a DataSource I often include a parameter in the URL as
below:

myNewPage.aspx?myParam = 10

If I simply need to use the value of myParam in the VB code when the new
page load, how do I refer to the parameter?

e.g. myLabel.Text = myParam (where myParam is replaced with a proper way
to refer to it)

TIRislaa



Dec 14 '06 #4

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

Similar topics

2
by: zlatko | last post by:
There is a form in an Access Project (.adp, Access front end with SQL Server) for entering data into a table for temporary storing. Then, by clicking a botton, several action stored procedures...
3
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) {...
12
by: Joel | last post by:
Hi all, Forgive me if I've expressed the subject line ill. What I'm trying to do is to call a c++ function given the following: a. A function name. This would be used to fetch a list of...
7
by: Harolds | last post by:
The code below worked in VS 2003 & dotnet framework 1.1 but now in VS 2005 the pmID is evaluated to "" instead of what the value is set to: .... xmlItems.Document = pmXML // Add the pmID...
2
by: Bob | last post by:
I'm new to Access projects and SQL server and am not a veteran VB programmer. There's a cry for help! I'm attempting to print the current form on screen by using a command button which the user...
17
by: Charles Sullivan | last post by:
The library function 'qsort' is declared thus: void qsort(void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *)); If in my code I write: int cmp_fcn(...); int...
8
by: Johnny | last post by:
I'm a rookie at C# and OO so please don't laugh! I have a form (fclsTaxCalculator) that contains a text box (tboxZipCode) containing a zip code. The user can enter a zip code in the text box and...
4
by: Nathan Sokalski | last post by:
I am a beginner with AJAX, and have managed to learn how to use it when passing single parameters, but I want to return more than one value to the client-side JavaScript function that displays it....
2
by: luis | last post by:
I'm using ctypes to call a fortran dll from python. I have no problems passing integer and double arryas, but I have an error with str arrys. For example: ..... StringVector = c_char_p *...
3
by: ajaymohank | last post by:
hello everyone..... i am ajay and i am new to php. in my project i have an option to invoke a bat file by passing parrameters and to diplay the result. i tried this code but my page got hung or...
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: 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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.