Tuka
Tuka

Reputation:

Adding a condition in the url

I would line to add a test condition in an asp.net form such that:

1) From page1.aspx I manually add a query string parameter so that I can trigger the rest of the process in test mode like so: page1.aspx?test=true . This flag must be added in the query string. 2) When I click on a asp.net button in page1.aspx, I am redirected to page2.aspx in test mode because of teh attached querystring

It seems that I have to work around the postback model of asp.net this is not very straight forward.

Any idea how I can achieve the above behavior?

Thanks

Upvotes: 0

Views: 972

Answers (2)

JMP
JMP

Reputation: 7844

It sounds like you're using a form that posts, but you want to stay in "test" mode. That is, you're not using HTTP-GET so it's not realistic to pass QS variables around.

What I'd do is stash a variable in your Session to set the user's session test mode. So adding &test=true would trigger a Session["TestMode"] = true; before you move to the next page.

Upvotes: 2

SLaks
SLaks

Reputation: 887657

Try this (in server-side code)

Response.Redirect("Page2.aspx?Test=" + Request.QueryString["Test"]);

Upvotes: 0

Related Questions