ASP DropDownList UpdatePanel IE JS 错误
我在使用 IE 时遇到了一个特殊的 javascript 错误。 我有一个更新面板,里面有一个下拉列表。 当我更改下拉列表的值时,它给出错误“Line: 5 '__EVENTTARGET' is null or not an object”。 我看了一下,第 5 行和 __EVENTTARGET 位于 ASP.NET 生成的 javascript 代码中。
我想要一个下拉列表,在选择新选项时触发方法,并且没有页面闪烁。
这是我的一些代码:
<asp:ScriptManager ID="uxScriptMan" runat="server" />
<asp:UpdatePanel ID="uxtestupdatepanel" runat="server">
<ContentTemplate>
<asp:DropDownList ID="DropDownList1" runat="server"
AutoPostBack="true" OnSelectedIndexChanged="TESTMETHOD">
<asp:ListItem Text="TEST" Selected="true" />
<asp:ListItem Text="Yes" Value="1" />
<asp:ListItem Text="No" Value="0" />
</asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>
在
protected void TESTMETHOD(object sender, EventArgs e) { /*do nothing*/ }
Firefox 中,它可以工作,没有错误。 事实上,在开发机器上,未编译的 soln 包含 .aspx 和 .aspx.cs 文件,在 IE 中没有错误。 在生产机器上,编译后,我收到 IE js 错误。
有什么问题,我该如何解决,或者至少我可以从哪里开始寻找? 进行了大量的谷歌搜索,但运气不佳。
I'm getting a peculiar javascript error with IE.
I have an updatepanel, and inside it a drop down list. When I change the dropdownlist's value, it gives me error "Line: 5 '__EVENTTARGET' is null or not an object'.
I took a look, and this Line 5 and __EVENTTARGET are in the ASP.NET generated javascript code.
I want a dropdownlist that fires method when new option selected, with no page flicker.
Here's some of my code :
<asp:ScriptManager ID="uxScriptMan" runat="server" />
<asp:UpdatePanel ID="uxtestupdatepanel" runat="server">
<ContentTemplate>
<asp:DropDownList ID="DropDownList1" runat="server"
AutoPostBack="true" OnSelectedIndexChanged="TESTMETHOD">
<asp:ListItem Text="TEST" Selected="true" />
<asp:ListItem Text="Yes" Value="1" />
<asp:ListItem Text="No" Value="0" />
</asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>
and
protected void TESTMETHOD(object sender, EventArgs e) { /*do nothing*/ }
In Firefox, it works, no errors. And in fact, on dev machine, uncompiled soln with .aspx and .aspx.cs files, no errors in IE. On production machine, compiled, I get IE js errors.
Whats the problem, how do i fix, or at least, where can I start looking? Done a ton of googling with not much luck.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
摸索一下,您的服务器是否具有与您的开发环境相同的服务包?
如果您使用的是 .NET 3.5 SP1,则服务包会产生很大的差异,并且可能会导致奇怪的差异。
A shot in the dark, does your server have the same service packs as your development environment?
If you're using .NET 3.5 SP1, the service pack makes a big difference and could account for the odd discrepancy.
两者的 web.config 是否相同? 您的生产版本可能缺少 ScriptResource.axd 的资源处理程序
Do you have the same web.config in both? Your production one may be missing the resource handler for ScriptResource.axd
修复! 这是 Duck 和 ck 评论的结合。
多谢你们。
这是一个 web.config 问题。 这个特定应用程序的 web.config 与我们在服务器上使用的其他一些应用程序不同。 以下是针对遇到此问题的其他人的修复方法。
不正确的 web.config:
正确的 web.config:
Fixed it! It was a combination of Duck and ck's comments.
Thanks guys.
It was a web.config problem. This particular application's web.config was different from a few other applications we had been using on our servers. Here's the fixes for anyone else who ever has this problem.
Incorrect web.config:
Correct web.config:
尝试设置 ScriptManager EnablePartialRendering 属性
并查看是否仍然收到错误
另请尝试关闭该页面上的事件验证
并查看是否仍然收到错误
Try setting the ScriptManager EnablePartialRendering property
And see if you still get an error
Also try turning off event validation on that page
And see if you still get an error