Possible Duplicate:
redirect to new page when i click on Cancel button in C# (webpart)
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();
tc = new Table开发者_StackOverflow中文版Cell();
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#
In your event handler, you should be able to do something as simple as:
protected void btnCancel_Click(object sender, EventArgs e)
{
Page.Response.Redirect("Example.aspx");
}
If I were building a WebPart though, I would make the redirect URL a parameter so that you can re-use the control:
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");
}
}
You posted this not half an hour ago and got three answers already.
redirect to new page when i click on Cancel button in C# (webpart)
精彩评论