use*_*048 34 asp.net webforms button visual-studio-2013
如何对按钮进行编码,以便在单击按钮时将其带到另一个Web表单?假设按钮名称为Confirm,结婚格式为confirm.aspx?
protected void btnConfirm_Click(object sender, EventArgs e)
{
(guessing that there should be an input here)
}
Run Code Online (Sandbox Code Playgroud)
Rex*_*Rex 48
您可以执行按钮单击事件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");
}
Run Code Online (Sandbox Code Playgroud)
小智 12
您可以使用 PostBackUrl="~/Confirm.aspx"
例如:
在.aspx文件中
<asp:Button ID="btnConfirm" runat="server" Text="Confirm"
PostBackUrl="~/Confirm.aspx" />
或者在.cs文件中
btnConfirm.PostBackUrl="~/Confirm.aspx"
小智 6
你可以用这个:
protected void btnConfirm_Click(object sender, EventArgs e)
{
Response.Redirect("Confirm.aspx");
}
Run Code Online (Sandbox Code Playgroud)