用户控件的事件处理程序丢失回传 [英] user control event handler lost on postback

查看:72
本文介绍了用户控件的事件处理程序丢失回传的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为LeftMenu菜单用户控件有linkitems的BulletedList中。这是ASCX页面上这样的:

I have a menu usercontrol called LeftMenu that has a bulletedlist of linkitems. It's on the ascx page as such:

<asp:BulletedList ID="PublisherList" DisplayMode="LinkButton" OnClick="PublisherList_Click" cssClass="Menu" runat="server"></asp:BulletedList>

我数据绑定在Page_Load列表下的如果(!的IsPostBack)

我在加载该控件的页面上的问题。当第一次加载页面,事件处理火灾。然而,当页面回它不再火灾和IE8中,当我调试,我得到微软JScript运行时错误:预期的对象,在Visual Studio中的指向__doPostBack('LeftMenu $ PublisherList','0') 。在FF我没有得到的错误,但没有任何反应。我的不可以动态加载控件,它已载入使用aspx页面上:

I'm having an issue on a page that loads the control. When the page first loads, the event handler fires. However, when the page posts back it no longer fires and in IE8, when I'm debugging, I get "Microsoft JScript runtime error: Object expected" in Visual Studio pointing at "__doPostBack('LeftMenu$PublisherList','0')." In FF I don't get the error, but nothing happens. I'm not loading the control dynamically, it's loaded on the aspx page using:

<%@ Register TagPrefix="Standards" TagName="LeftMenu" Src="LeftMenu.ascx" %>

<Standards:LeftMenu ID="LeftMenu" runat="server"/>

在这里我失去了事件处理程序的任何想法?

Any ideas of where I'm losing the event handler?

我才意识到这是另一个用户控件我也一样发生。一个文本框和一个按钮和我使用默认按钮,以确保pressing回车键使用该按钮。净转换,在HTML中:

I just realized this is happening on another user control I have as well. A text box and a button and I'm using the default button to make sure pressing the enter key uses that button. .Net converts that in the html to:

 <div id="SearchBarInclude_SearchBar" onkeypress="javascript:return WebForm_FireDefaultButton(event, 'SearchBarInclude_QuickSearchButton')">

所以,只要我在框中输入我得到在该行JavaScript错误说一个关键对象的预期。这似乎是两个问题是相关的。

so as soon as i enter a key in the box I get a javascript error at the line saying "object expected." It seems like the two issues are related.

再次编辑:我想我需要澄清。这并不是说我点击菜单项,它无法找到回发所选择的项目。我与它的左侧导航这个搜索页面,然后页面的主要内容是什么,导致回发。一切都很好与此回发。一旦该页面已被贴后背,现在如果我点击项目符号列表在左侧导航我得到一个JavaScript错误和失败。对于LeftMenu控制的page_init不会被调用。

Edit Again: I think I need to clarify. It's not that I'm clicking on the menu item and it can't find the selected item on postback. I have this search page with the left navigation on it and then the main content of the page is something that causes a postback. Everything is fine with this postback. Once that page has been posted back, now if I click on the bulleted list in the left navigation I get a javascript error and it fails. The page_init for the LeftMenu control is never called.

推荐答案

我有一个类似的问题。原来,Akamai的是修改用户代理字符串,因为正在应用的设置,是没有必要的。

I had a similar issue. It turned out that Akamai was modifying the user-agent string because an setting was being applied that was not needed.

这意味着一些.NET控件没有呈现__doPostBack code正确。这个问题已经在博客<一href=\"http://www.dotnetlite.com/2010/06/21/loss-of-__dopostback-$c$c-after-protecting-a-site-with-akamai/\"相对=nofollow>这里。

This meant that some .NET controls did not render __doPostBack code properly. This issue has been blogged here.

这篇关于用户控件的事件处理程序丢失回传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆