redirect to new page when i click on Cancel button in C# (webpart)

后端 未结 3 1695
庸人自扰
庸人自扰 2021-01-26 18:34
// Cancel button
            tc = new TableCell();
            btnCancel = new Button();
            btnCancel.Text = \"Cancel\";
            btnCancel.Click += new Even         


        
相关标签:
3条回答
  • 2021-01-26 18:49

    Call the HttpResponse.Redirect Method.

    Example:

    Response.Redirect("Example.aspx");
    
    0 讨论(0)
  • 2021-01-26 19:09

    To do exactly what you want, on the server, would be Response.Redirect. There is no need to postback though. There are a few client side solutions. Use a LinkButton, w/ onclick html attribute set to false. My recommendation is something like this though:

    <INPUT TYPE="BUTTON" VALUE="Cancel" ONCLICK="window.location.href='http://www.yourdomain.com/example.aspx'"> 
    
    0 讨论(0)
  • 2021-01-26 19:11
    protected void btnCanel_Click(object sender, EventArgs e)
    {
        Response.Redirect("example.aspx");
    }
    
    0 讨论(0)
提交回复
热议问题