C#中 点击按钮刷新其它一个界面(点击子界面按钮,刷新父界面)

子界面是父界面弹出的新界面。操作子界面刷新父界面(功能新增属性过后,父界面刷新出来),满意追加50+
追加100+

    public partial class frmParent : Form
    {
        public frmParent()
        {
            InitializeComponent();

        }

        private void frmParent_Load(object sender, EventArgs e)
        {
            frmChild child = new frmChild();

            child.RefreshEvent += this.NeedRefresh;//注册事件
            child.Show();
        }

        private void NeedRefresh(object sender, EventArgs e)
        {
            MessageBox.Show("需要刷新!");
            //在这里写刷新逻辑
        }
    }

    public partial class frmChild : Form
    {
        public event EventHandler RefreshEvent;

        public frmChild()
        {
            InitializeComponent();
        }

 
        private void button1_Click(object sender, EventArgs e)
        {
            //在需要的时候,调用下面这段,引发刷新事件
            //比如现在是点击button1的时候引发
            if (this.RefreshEvent != null)
            {
                RefreshEvent(this, null);
            }
        }
    }

追问

大哥,这是winform的吗?网站可以这样处理不
protected void Button1_Click(object sender, EventArgs e){

}
需要在这里面写

追答

可以的。

温馨提示:内容为网友见解,仅供参考
第1个回答  2014-06-06
window.top.location.reload( );追问

这个是如何指定到父界面的url的哦,刷新父界面(网页中弹出的新页面)不需要传递什么值么?

追答

这个直接指定的你上一个页面

追问

父界面的url manageC3.aspx,子界面的updateC3.aspx。那么上面的window.top.location.reload();是写在子界面的啊。如下
protected void Button1_Click(object sender, EventArgs e){
window.top.location.reload(" manageC3.aspx");
}
是这样写的吗?

追答

你是不是不会javascript?你是要用后台实现吗

http://wuyawei4062.blog.163.com/blog/static/454123362010816101440255/

这有案例,你研究下吧

本回答被提问者采纳
第2个回答  2014-06-06
sdfasdfasdfasdfas key de
相似回答