使用Webpart中的C#按钮重定向到新页面 [英] redirect to new page using C# button in webpart

查看:91
本文介绍了使用Webpart中的C#按钮重定向到新页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

    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 TableCell();
    tr.Controls.Add(tc);

    this.Controls.Add(t);
}

protected void btnCanel_Click(object sender, EventArgs e)
{

}




我正想做的是.当我单击取消"按钮时,它将我重定向到"Example.aspx".
我正在使用C#创建一个Webpart

[edit]添加了代码块-OriginalGriff [/edit]




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#

[edit]Code block added - OriginalGriff[/edit]

推荐答案

为什么不将PostbackUrl属性设置为要重定向到的URL? (顺便说一句,当您这样做时,它不会触发Button.Click事件.
Why don''t you set the PostbackUrl property to the url you want to redirect to? (BTW, when you do that, it will not fire the Button.Click event.


您可以使用SPUtility.Redirect方法

SPUtility.Redirect方法 [
you could use SPUtility.Redirect Method

SPUtility.Redirect Method[^]

If this is asp.net webpart you are talking about, redirection just works fine.


这篇关于使用Webpart中的C#按钮重定向到新页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆