重定向到新的页面,当我点击在C#中取消按钮(web部件) [英] redirect to new page when i click on Cancel button in C# (webpart)

查看:133
本文介绍了重定向到新的页面,当我点击在C#中取消按钮(web部件)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

            this.Controls.Add(t);
        }

        protected void btnCanel_Click(object sender, EventArgs e)
        {

        }

什么,我特林做的是。当我点击取消按钮,它重定向我Example.aspx。
I正在使用C#

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#

推荐答案

要做到你想要什么,在服务器上,将创建一个web部件<一个HREF =http://msdn.microsoft.com/en-us/library/a8wa7sdt%28v=VS.100%29.aspx相对=nofollow> Response.Redirect的。没有必要对虽然回发。有几个客户端解决方案。使用一个LinkBut​​ton,瓦特/ HTML的onclick属性设置为false。我的建议是这样的,虽然:

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

这篇关于重定向到新的页面,当我点击在C#中取消按钮(web部件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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