ASP.NET DIV弹出层

本文介绍了一个使用ASP.NET实现的弹出窗口功能及其与主页面之间的交互机制,详细解析了如何通过按钮触发弹窗并实现数据保存后主页面的自动刷新。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

原页面

*list.ascx

<div style="display:none;"><a  id="a_add" href="UnitsEdit.aspx?ObjectId=0" class="contFormInit" onclick="$('.contFormInit').colorbox({ width: '550px', height: '300px'});" >Add</a> </div>
<div style="display:none;"><asp:Button ID="bt_F5" runat="server"></asp:Button></div>

弹出层

*edit.ascx

<asp:LinkButton ID="lbt_Add" runat="server">Save</asp:LinkButton>
<a href="javascript:parent.CancelWindow();">Cancel</a>

*edit.cs

    void lbt_Add_Click(object sender, EventArgs e)
    {
       Response.Write("<script>javascript:parent.MyF5();</script>");
       Response.End();
    }


masterPage

.master

 <script type="text/javascript">
    $(document).ready(function() {
        $('.contFormInit').colorbox({ iframe: true, width: '550px', height: '550px', overlayClose: false });

        $(document).bind('cbox_closed', function() {
            MyF5();
        });

    });
 ...
    </script>

BasePart.cs

       private Button _bt_F5;
 protected Button bt_F5
 {
 #region GetControl
 get
 {
 if (string.IsNullOrEmpty(F5_Id))
 {
 F5_Id = "bt_F5";
 }

 if (_bt_F5 == null)
 {
 _bt_F5 = this.FindControl(F5_Id) as Button;
 }
 return _bt_F5;
 }
 #endregion
 }
...
        protected override void OnPreRender(EventArgs e)
        {
            if (bt_F5 != null)
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), this.ClientID + "F5click", "function MyF5(){ $('#" + bt_F5.ClientID + "').click() }", true);
            }
        }

...
 protected override void InitializeSkin(Control skin)
 {
 if (bt_F5 != null)
 {
 bt_F5.Click += new EventHandler(F5_Click);
 }

 }

protected virtual void F5_Click(object sender, EventArgs e)
 {
 this.ReDataBindInPage(this.Page);
 }



 protected void ReDataBindInPage(Control page)
        {
            foreach (Control _item0 in page.Controls)
            {
                if (_item0 is UserControl)
                {
                    Type _type = _item0.GetType();
                    MethodInfo Mymethodinfo = _type.GetMethod("DataBind");
                    Mymethodinfo.Invoke(_item0, null);

                }
                ReDataBindInPage(_item0);
            }
        }




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值