当我单击C#(Web部件)中的“取消”按钮时,重定向到新页面[重复]

|                                                                                                                   这个问题已经在这里有了答案:                                                      
已邀请:
        在事件处理程序中,您应该能够执行以下操作:
protected void btnCancel_Click(object sender, EventArgs e)
{
    Page.Response.Redirect(\"Example.aspx\");
}
如果我正在构建WebPart,则可以将重定向URL用作参数,以便您可以重新使用控件:
public class YourWebPart
{
    public string CancelUrl { get; set; }

    protected override void CreateChildControls()
    {
        // Build the part
    }

    protected void btnCancel_Click(object sender, EventArgs e)
    {
        Page.Response.Redirect(CancelUrl ?? \"Example.aspx\");
    }
}
    
        您在半小时前发布了此信息,并且已经获得了三个答案。 当我单击C#中的“取消”按钮(Webpart)时,重定向到新页面     

要回复问题请先登录注册