日期:2014-05-18  浏览次数:20365 次

asp.net中 CS1061错误
源码:
<asp:Button ID="Button3" runat="server" Text="Button" OnClick='window.frames["iframeWeather"].location.href="./NewsContent.aspx"' />

错误:
编译器错误消息: CS1061: “ASP.z_ctrltest_aspx”不包含“window”的定义,并且找不到可接受类型为“ASP.z_ctrltest_aspx”的第一个参数的扩展方法“window”(是否缺少 using 指令或程序集引用?)

疑惑:
下面源码可以正常运行,为什么在asp:button中就报错呢?
<input type="button" id="Button2" runat="server" value="Button" onclick='window.frames["iframeWeather"].location.href="./NewsContent.aspx"' />
 

------解决方案--------------------
OnClick改成OnClientClick