看到一篇老外的介绍,介绍如何在弹出的窗口中引发父窗口的postback事件,现转载如下:
首先,建立main.aspx文件,写入如下代码,其中的一个按钮设置为visiable,只是为了效果而设置。
<script language="javascript">
//To cause postback "as" the Button
function PostBackOnMainPage(){
<%=Page.GetPostBackEventReference(btnPostBack)%>
}
//Helper just to open popup
function openPopUp(){
window.open('popup.aspx','popup','width=400,height=100');
//Maybe handling something else also, like giving extra arguments etc etc
}
</script>
<script runat="server" language="VB">
'This is to react to the postback
Protected Sub btnPostBack_Click(ByVal sender As Object, ByVal e As EventArgs)
lblShowPostInfo.Text = "Postback happened: " & DateTime.Now.ToString()
End Sub
</script>
<form />
作用是点这个按钮,引发父窗口的postbackonmainpage()事件