ASP.NET button redirect to a new page

I created the program programmatically. Now I want to redirect to a new aspx page by clicking this button so that we enter one of the methods of the new page (for example, page_load (), etc.).

Is it possible?

For instance:

Button oButton = new Button;
oButton.Text = "NextPage";
// Redirect to "Redirect.aspx" on click

But I can’t find the entry point in Redirect.aspx, where I can make some changes to the interface components after we redirect to "Redirect.aspx"

Hi,

Parag

+5
source share
3 answers

You can use the query string parameters and, depending on the param value, call the corresponding method in Page_Load Redirect.aspx for example.

Redirect.aspx?val=1

in redirect.aspx

protected void Page_Load(...){
string var = Request.QueryString["val"];
if(var == "1")
some_method();
else
some_other_method();
}
+2
source

Click oButton.

Button oButton = new Button();
 oButton.Text = "NextPage";
 oButton.Click += (sa, ea) =>
     {
         Response.Redirect("Redirect.aspx");
   };
+6

PostBackUrl Button - , , PreviousPage:

Button oButton = new Button;
oButton.Text = "NextPage";
oButton.PostBackUrl = "Redirect.aspx";

, , TextBox txtMyInput, ( , ):

void Page_Load(object sender, EventArgs e)
{

   string myInputText = ((TextBox)PreviousPage.FindControl("txtMyInput")).Text;

   // Do something with/based on the value.

}

, , .

. Button.PostBackUrl Property.

+2

All Articles