我搜索过所以,谷歌,但我似乎不能让这个工作。代码位于我的asp.net应用程序中的“取消”按钮的代码背后单击事件,但似乎没有关闭弹出窗口。有什么想法吗?
try
{
if (btnCancel.Text == "Close")
{
String csName1 = "PopupScript";
Type csType = this.GetType();
ClientScriptManager cs = Page.ClientScript;
if (!cs.IsClientScriptBlockRegistered(csType, csName1))
{
ClientScript.RegisterStartupScript(GetType(), "ClosePopup", "window.close();", true);
}
}
} 更新:回发后的,当我查看源代码页时,我看到的唯一相关代码是:
//<![CDATA[
(function() {var fn = function() {$get("ToolkitScriptManager1_HiddenField").value = '';Sys.Application.remove_init(fn);};Sys.Application.add_init(fn);})();window.close();
document.getElementById('ValidationSummary1').dispose = function() {
Array.remove(Page_ValidationSummaries, document.getElementById('ValidationSummary1'));
}发布于 2013-08-29 20:58:15
由于无法使ClientScript按要求工作,所以我使用以下代码解决了问题:
function closeWin() {
//If txt = 'cancel' then close;
GetRadWindow().Close();
}
<td align="center"><asp:Button runat="server" ID="btnClose" Text="Close"
OnClientClick="closeWin();return false;" onclick="btnClose_Click"/></td>发布于 2013-05-11 02:17:11
你可以用这个代替
ScriptManager.RegisterStartupScript(this.Page, GetType(), "ClosePopup", "window.close();", true);或者你也可以试试这个
Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "ClosePopup", "window.close();", true);祝你今天愉快。
https://stackoverflow.com/questions/16484978
复制相似问题