ASP.NET按钮重定向到另一个页面

时间:2022-11-09 03:30:53

How do I code the button such that when I click the button and it brings me to another web form? Let's say the button name is Confirm and the wed form is confirm.aspx ?

如何对按钮进行编码,以便在单击按钮时将其带到另一个Web表单?假设按钮名称为Confirm,结婚格式为confirm.aspx?

    protected void btnConfirm_Click(object sender, EventArgs e)
    {
        (guessing that there should be an input here)
    }

3 个解决方案

#1


36  

You can either do a Response.Redirect("YourPage.aspx"); or a Server.Transfer("YourPage.aspx"); on your button click event. So it's gonna be like the following:

你可以做一个Response.Redirect(“YourPage.aspx”);或Server.Transfer(“YourPage.aspx”);在你的按钮点击事件。所以它会像下面这样:

protected void btnConfirm_Click(object sender, EventArgs e)
{
    Response.Redirect("YourPage.aspx");
    //or
    Server.Transfer("YourPage.aspx");
}

#2


11  

You can use PostBackUrl="~/Confirm.aspx"

你可以使用PostBackUrl =“〜/ Confirm.aspx”

For example:

例如:

In your .aspx file

在.aspx文件中

<asp:Button ID="btnConfirm" runat="server" Text="Confirm" PostBackUrl="~/Confirm.aspx" />

or in your .cs file

或者在.cs文件中

btnConfirm.PostBackUrl="~/Confirm.aspx"

btnConfirm.PostBackUrl = “〜/ Confirm.aspx”

#3


5  

u can use this:

你可以用这个:

protected void btnConfirm_Click(object sender, EventArgs e)
{
  Response.Redirect("Confirm.aspx");
}

#1


36  

You can either do a Response.Redirect("YourPage.aspx"); or a Server.Transfer("YourPage.aspx"); on your button click event. So it's gonna be like the following:

你可以做一个Response.Redirect(“YourPage.aspx”);或Server.Transfer(“YourPage.aspx”);在你的按钮点击事件。所以它会像下面这样:

protected void btnConfirm_Click(object sender, EventArgs e)
{
    Response.Redirect("YourPage.aspx");
    //or
    Server.Transfer("YourPage.aspx");
}

#2


11  

You can use PostBackUrl="~/Confirm.aspx"

你可以使用PostBackUrl =“〜/ Confirm.aspx”

For example:

例如:

In your .aspx file

在.aspx文件中

<asp:Button ID="btnConfirm" runat="server" Text="Confirm" PostBackUrl="~/Confirm.aspx" />

or in your .cs file

或者在.cs文件中

btnConfirm.PostBackUrl="~/Confirm.aspx"

btnConfirm.PostBackUrl = “〜/ Confirm.aspx”

#3


5  

u can use this:

你可以用这个:

protected void btnConfirm_Click(object sender, EventArgs e)
{
  Response.Redirect("Confirm.aspx");
}