原页面
*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);
}
}