Using HTTP Parameters with C# and .NET

  • Thread starter Thread starter Peter
  • Start date Start date
P

Peter

I have a question as below:
.. one.htm calls two.aspx page with parameter as below:
.. two.aspx?para1=hello
.. in two.aspx.cs file, how do I use the parameter?
Please advice.
 
Peter -

This is how you would access parameters passed through the querystring:

Request.Querystring("para1")

Hope this helps.

Bart A. Robinson, MCP
 
In the Page_Load function, you can read this value into a local variable.
Eg.

string strParam = "Default Value";

if (Request.QueryString.Get("para1") != string.Empty)
{
strParam = Request.QueryString.Get("para1")
}

Hope this helps,

Mun
 
Or, you could use the indexer

string paramVal = Request["param1"];


HTH
Brian W
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top