[英]How to make previous page refresh after I click a button in pop-up window?
My main page has a GridView
and Button
s for add/update. 我的主页上有一个
GridView
和Button
用于添加/更新。 When I click the update button, a window pops up(used JavaScript
) which has input fields and a Button
for actually updating the record. 当我单击更新按钮时,会弹出一个窗口(使用
JavaScript
),该窗口具有输入字段和一个用于实际更新记录的Button
。 What I want to know is how to refresh the main page when I click the update button inside the pop-up window. 我想知道的是单击弹出窗口中的更新按钮时如何刷新主页。
This is the partial code of what I tried on actual update's OnClick
: 这是我在实际更新的
OnClick
上尝试过的部分代码:
if (PreviousPage != null)
{
GridView gridv = (GridView)Page.PreviousPage.FindControl("GridView1");
gridv.DataBind();
}
While debugging, I realized that the if statement was never executed. 在调试时,我意识到if语句从未执行过。 Does that mean pop-up windows do not have a
PreviousPage
initially? 这是否意味着弹出窗口最初不具有
PreviousPage
? If so how can I reach the Main page then? 如果可以,我如何进入主页 ? (i shall note that the main page is not a master page)
(我应注意,主页不是母版页)
This is how I create the pop-up on button click from the Main page(so it's a new window): 这是我从主页上单击按钮创建弹出式窗口的方式(因此这是一个新窗口):
function btnEditEP_Click() {
var recID = document.getElementById('<%=tboxEdit.ClientID%>').value;
window.open("editPopupEP.aspx?Txt=" + recID, "_blank", "toolbar=yes", "resizable=yes", "scrollbars=yes");
}
On your child window you can call a function something like this in your child window call on your update function 在您的子窗口中,您可以在更新功能的子窗口中调用类似这样的函数
<script type="text/javascript">
function MyFunction() {
window.opener.PostBackParentWindow();
window.close();
}
</script>
and in your parent window call add this code 并在您的父窗口调用中添加此代码
<script type="text/javascript">
function PostBackParentWindow() {
__doPostBack(null, null);
}
</script>
Hope it might help 希望对您有所帮助
On the update click also perform the close pop up call 在更新上,还单击执行关闭弹出呼叫
<script>
var popupWindow;
function openw(url) {
popupWindow = window.open(url, "popup", "");
}
function closew() {
if (popupWindow) {
popupWindow.close();
}
}
</script>
<a href="javascript:openw('about:blank')">open</a><br />
<a href="javascript:closew()">close</a>
like described here . 就像这里描述的那样。 How to close a popup window in a parent window?
如何在父窗口中关闭弹出窗口?
and then in closw
you can call your parent page with true/false value depending on your update operation. 然后在
closw
,根据更新操作,您可以使用true / false值调用父页面。 You can use a hiddenfield
for this. 您可以为此使用
hiddenfield
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.