简体   繁体   中英

Pass value between asp.net web page

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.

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.

String value = Request.QueryString["productId"];

建议您验证是否确实存在Request.QueryString [“ productId”]。

Use the request collection

string productId = Request["productId"];

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

如果ProductID是服务器端变量,请使用以下命令:NavigateUrl =“ Order.apx?productId =” <%= ProductID%>

Your code:

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

Remove the space My code:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM