0

I'm using asp.net with c# in backcode. On my first page, I have a hyperlink with NavigateUrl ="Order.aspx?productId = " + ProductID . I want to transfer ProductID in Order.aspx file. So, how to get it in target file :Order.aspx.

I used a lable to display in Order.aspx file

string productId = Request.QueryString["productId"];

lblTest.Test = productId

But lblTest didn't display anything

Thanks.

1
  • Please rephrase your question Commented Nov 29, 2011 at 21:52

5 Answers 5

4

You would read the QueryString values of the Request object.

string productId = Request.QueryString["productId"]; 

You'd have to parse it into an integer if that is what it is.

NavigateUrl ="Order.aspx?productId = " + ProductID 

You might also want to get rid of the spaces in your URL.

Sign up to request clarification or add additional context in comments.

1 Comment

Like I said, change your URL. The spaces in proudctId = might cause you problems. Debug the page and see what Request.QueryString["productId"] is returning.
1
String value = Request.QueryString["productId"]; 

Its advisable that you verify whether Request.QueryString["productId"] is really present.

Comments

0

Use the request collection

string productId = Request["productId"]; 

Be careful what you do with this variable. E.g. don't store it directly in a database or append it to an inline query.

1 Comment

Incorrect. See here: hanselman.com/blog/…
0

If ProductID is a server-side variable, use this: NavigateUrl = "Order.apx?productId = "<% =ProductID %>

Comments

0

Your code:

="Order.aspx?productId = " + ProductID; 

Remove the space My code:

="Order.aspx?productId=" + ProductID; 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.