以下是我的测试代码:
<%@ Language="C#" %>
<script language="C#" runat="server">
void Btn_Close(object sender ,EventArgs e)
{
Response.Write("<script>window.opener=null;window.close();</script>");// 不会弹出询......
}
void Btn_Click(object sender ,EventArgs e)
{
Response.Write("<script>window.close();</script>");// 会弹出询问是否关闭
}
</script>
<form runat="server">
<p><asp:Button id="Button1" Text="不弹出对话框Close" width="200px" OnClick="Btn_Close" runat="server" />
<p><asp:Button id="Button2" Text="弹出对话框的Close" width="200px" OnClick="Btn_Click" runat="server" />
</form>
出现了如下编译信息:
Server Error in '/' Application.
--------------------------------------------------------------------------------
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS1010: Newline in constant
Source Error:
Line 7: {
Line 8:
Line 9: Response.Write("<script>window.opener=null;window.close();</script>");// 不会弹出询......
Line 10:
Line 11: }
Source File: c:\Inetpub\wwwroot\MyWebSite\Close_IE.aspx Line: 9
Show Detailed Compiler Output:
C:\WINDOWS\system32> "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\csc.exe" /t:library /utf8output /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Web.Services\2.0.0.0__b03f5f7f11d50a3a\System.Web.Services.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Xml\2.0.0.0__b77a5c561934e089\System.Xml.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll" /R:"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll" /R:"C:\WINDOWS\assembly\GAC_32\System.Data\2.0.0.0__b77a5c561934e089\System.Data.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Configuration\2.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Drawing\2.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll" /R:"C:\WINDOWS\assembly\GAC_32\System.EnterpriseServices\2.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll" /R:"C:\WINDOWS\assembly\GAC_32\System.Web\2.0.0.0__b03f5f7f11d50a3a\System.Web.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Web.Mobile\2.0.0.0__b03f5f7f11d50a3a\System.Web.Mobile.dll" /out:"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\77143044\e1bbbc9c\App_Web_6genyji7.dll" /debug- /optimize+ /w:4 /nowarn:1659;1699 "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\77143044\e1bbbc9c\App_Web_6genyji7.0.cs" "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\77143044\e1bbbc9c\App_Web_6genyji7.1.cs"
Microsoft (R) Visual C# 2005 Compiler version 8.00.50727.42
for Microsoft (R) Windows (R) 2005 Framework version 2.0.50727
Copyright (C) Microsoft Corporation 2001-2005. All rights reserved.
c:\Inetpub\wwwroot\MyWebSite\Close_IE.aspx(9,17): error CS1010: Newline in constant
c:\Inetpub\wwwroot\MyWebSite\Close_IE.aspx(9,60): error CS1513: } expected
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42
请问是什么原因?谢谢!