开发者

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

// Cancel button
            tc = new TableCell();
            btnCancel = new Button();
            btnCancel.Text = "Cancel";
            btnCancel.Click += new EventHandler (btnCanel_Click ) ;
            tc.Controls.Add(btnCancel);
            tr.Controls.Add(tc);

            t.Controls.Add(tr);


            // Empty table cell
            tr = new TableRow();
  开发者_JS百科          tc = new TableCell();
            tr.Controls.Add(tc);

            this.Controls.Add(t);
        }

        protected void btnCanel_Click(object sender, EventArgs e)
        {

        }

What i am tring to do is . when i click on Cancel button it redirect me to "Example.aspx". i am create a webpart using C#


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


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'"> 


Call the HttpResponse.Redirect Method.

Example:

Response.Redirect("Example.aspx");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜