Bruce
Bruce

Reputation: 8879

Asp.net redirect to another page

In my page when edit button pressed it should go to edit page with filled form elements

if (e.CommandName == "edit")
  {
     dataaccess.Instance.get(Convert.ToInt32(e.CommandArgument));
     //code here
  }

How redirect to another page with a value(e.g id)

Upvotes: 0

Views: 1541

Answers (3)

SOLOMON SARKAR
SOLOMON SARKAR

Reputation: 83

Just pass the value from First page using Query String

Response.Redirect("thankyou.aspx?id="+e.CommandArgument);

And get the value in other page's page load method using

string ID = Request.QueryString["ID"].ToString();

It's the easiest way to pass and get the variable between page but Query string is visible in Address bar chances of hacking or SQL Injection is more.

For that you can Encrypt the Query String before pass it in URL.

OR

You can use Session Variable too. which is more secure than Query String.

Upvotes: 1

Sumithlal
Sumithlal

Reputation: 393

You can use query string for this.

Upvotes: -1

Saurabh
Saurabh

Reputation: 5727

Response.Redirect("redirectpage.aspx?id="+e.CommandArgument);

Upvotes: 1

Related Questions