现在的位置: 首页 > 综合 > 正文

[原创]如何在关闭当前页面时刷新父页面(调用它的页面),或者触发父页面的某个事件或方法

2013年04月05日 ⁄ 综合 ⁄ 共 666字 ⁄ 字号 评论关闭
首先在父页面中加一个隐藏的Linkbutton,不用设置它的Visible属性,只需把它显示的文字清空,如下所示:

<asp:linkbutton id="btnfresh" tabIndex="-1" Runat="server"></asp:linkbutton>

在这个Linkbutton的单击事件中写你关闭子页时需要触发的方法

 Private Sub btnfresh_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnfresh.Click
        ‘ Your Method

    End Sub

然后在父页面的Page_Load事件中写:
btnfresh.Attributes.Add("onfocus", "javascript:__doPostBack('btnfresh','');")

当Linkbutton获得焦点时触发单击事件

子页面的aspx文件中 加一段js

<script language="javascript">

function RefreshParent()
   {
   dialogArguments.document.all('btnfresh2').focus();   
   //dialogArguments.location.reload();
   }

</script>

<body onunload="RefreshParent()">

这样保证在子页面关闭时就给父页面的Linkbutton复了焦点,从而触发Linkbutton的单击事件。

抱歉!评论已关闭.