ASP DropDownList UpdatePanel IE JS 错误

发布于 2024-07-15 02:08:08 字数 1048 浏览 4 评论 0原文

我在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

苍风燃霜 2024-07-22 02:08:08

摸索一下,您的服务器是否具有与您的开发环境相同的服务包?

如果您使用的是 .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.

‖放下 2024-07-22 02:08:08

两者的 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

七分※倦醒 2024-07-22 02:08:08

修复! 这是 Duck 和 ck 评论的结合。

多谢你们。

这是一个 web.config 问题。 这个特定应用程序的 web.config 与我们在服务器上使用的其他一些应用程序不同。 以下是针对遇到此问题的其他人的修复方法。

不正确的 web.config:

<compilation debug="false">
        <assemblies>
            <add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            <add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
        </assemblies>
    </compilation>


 <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
            <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>
            <bindingRedirect oldVersion="1.0.61025.0" newVersion="3.5.0.0"/>
        </dependentAssembly>
    </assemblyBinding>
</runtime>

正确的 web.config:

<compilation debug="false">
  <assemblies>
    <add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
    <add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    <add assembly="System.Web.Extensions.Design, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    <add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
  </assemblies>

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:

<compilation debug="false">
        <assemblies>
            <add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            <add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
        </assemblies>
    </compilation>


 <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
            <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>
            <bindingRedirect oldVersion="1.0.61025.0" newVersion="3.5.0.0"/>
        </dependentAssembly>
    </assemblyBinding>
</runtime>

Correct web.config:

<compilation debug="false">
  <assemblies>
    <add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
    <add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    <add assembly="System.Web.Extensions.Design, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    <add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
  </assemblies>
无边思念无边月 2024-07-22 02:08:08

尝试设置 ScriptManager EnablePartialRendering 属性

EnablePartialRendering="false"

并查看是否仍然收到错误

另请尝试关闭该页面上的事件验证

<%@ Page EnableEventValidation="false" %>

并查看是否仍然收到错误

Try setting the ScriptManager EnablePartialRendering property

EnablePartialRendering="false"

And see if you still get an error

Also try turning off event validation on that page

<%@ Page EnableEventValidation="false" %>

And see if you still get an error

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文