I have asp.net button "OK" in html popup window. I after my logic done how close that popup window it self?
我在html弹出窗口中有asp.net按钮“确定”。在我的逻辑完成后,我自己的弹出窗口有多接近?
<asp:Button Id="btnOK" runat="server" AccessKey="<%$Resources:
wss,multipages_okbutton_accesskey%>" Width="70px" Text="<%$Resources:wss,
multipages_okbutton_text%>" OnClick="btnOK_Click" />
5 个解决方案
#1
11
All correct but there is another way if you want close the window in your code:
一切正确,但如果你想在你的代码中关闭窗口,还有另一种方法:
Suppose that the button ID is "ContineButton" and the click event handler name is "ContineButton_Click"
假设按钮ID是“ContineButton”并且click事件处理程序名称是“ContineButton_Click”
protected void ContineButton_Click(object sender, EventArgs e)
{
this.ClientScript.RegisterClientScriptBlock(this.GetType(), "Close", "window.close()", true);
}
#2
14
<asp:Button ID="btnOK" runat="server" OnClientClick="window.close(); return false;" Text="Close" />
#3
2
If there is a chance that your server side code may fail, and you need to keep the popup open to correct errors, the OnClientClick trick won't help. I do this with a PlaceHolder and a small script:
如果您的服务器端代码可能会失败,并且您需要保持弹出窗口打开以纠正错误,OnClientClick技巧将无济于事。我使用PlaceHolder和一个小脚本执行此操作:
<asp:PlaceHolder id="close_script" runat="server">
<script>window.close();</script>
</asp:PlaceHolder>
Then, in the button handler, set the Visible property of the PlaceHolder to close the popup (or leave it open:
然后,在按钮处理程序中,设置PlaceHolder的Visible属性以关闭弹出窗口(或保持打开状态:
protected void btnOK_Click(Object sender, EventArgs e) {
bool success = processPage();
close_script.Visible = success;
}
#4
0
That requires some javascript. Change your button markup to this:
这需要一些JavaScript。将按钮标记更改为:
<asp:Button Id="btnOK" runat="server" AccessKey="<%$Resources:
wss,multipages_okbutton_accesskey%>" Width="70px" Text="<%$Resources:wss,
multipages_okbutton_text%>" OnClick="btnOK_Click" OnClientClick="javascript:window.close(); return false;" />
#5
0
There are other things to consider here - an accessible site will work without JavaScript including opening and closing a popup window. It will be dumbed down, but still function. Take a look at this article:
这里还有其他需要考虑的事项 - 可访问的站点无需JavaScript即可工作,包括打开和关闭弹出窗口。它会变得愚蠢,但仍然有效。看看这篇文章:
#1
11
All correct but there is another way if you want close the window in your code:
一切正确,但如果你想在你的代码中关闭窗口,还有另一种方法:
Suppose that the button ID is "ContineButton" and the click event handler name is "ContineButton_Click"
假设按钮ID是“ContineButton”并且click事件处理程序名称是“ContineButton_Click”
protected void ContineButton_Click(object sender, EventArgs e)
{
this.ClientScript.RegisterClientScriptBlock(this.GetType(), "Close", "window.close()", true);
}
#2
14
<asp:Button ID="btnOK" runat="server" OnClientClick="window.close(); return false;" Text="Close" />
#3
2
If there is a chance that your server side code may fail, and you need to keep the popup open to correct errors, the OnClientClick trick won't help. I do this with a PlaceHolder and a small script:
如果您的服务器端代码可能会失败,并且您需要保持弹出窗口打开以纠正错误,OnClientClick技巧将无济于事。我使用PlaceHolder和一个小脚本执行此操作:
<asp:PlaceHolder id="close_script" runat="server">
<script>window.close();</script>
</asp:PlaceHolder>
Then, in the button handler, set the Visible property of the PlaceHolder to close the popup (or leave it open:
然后,在按钮处理程序中,设置PlaceHolder的Visible属性以关闭弹出窗口(或保持打开状态:
protected void btnOK_Click(Object sender, EventArgs e) {
bool success = processPage();
close_script.Visible = success;
}
#4
0
That requires some javascript. Change your button markup to this:
这需要一些JavaScript。将按钮标记更改为:
<asp:Button Id="btnOK" runat="server" AccessKey="<%$Resources:
wss,multipages_okbutton_accesskey%>" Width="70px" Text="<%$Resources:wss,
multipages_okbutton_text%>" OnClick="btnOK_Click" OnClientClick="javascript:window.close(); return false;" />
#5
0
There are other things to consider here - an accessible site will work without JavaScript including opening and closing a popup window. It will be dumbed down, but still function. Take a look at this article:
这里还有其他需要考虑的事项 - 可访问的站点无需JavaScript即可工作,包括打开和关闭弹出窗口。它会变得愚蠢,但仍然有效。看看这篇文章: