ASP.NET的UpdatePanel不与火狐
我试图做一些听起来相当简单的使用ASP.NET 3.5。用户应该能够在数据库中添加一个“社区”,并在选中一个框后,从DropDown菜单中选择一个父社区,该菜单仅在复选框被选中时才显示。为此,我在UpdatePanel中使用了一个Panel(最初设置为Visible = false)。我的问题是,虽然它在IE8和Chrome中工作(尽管Chrome重新加载整个页面而不是只是div),但在Firefox中没有任何反应。没有询问发送在所有。我应该提到,下面的所有代码都位于用户控制页面中,而不仅仅是一个Web窗体。ASP.NET的UpdatePanel不与火狐
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="CommunityEditing.ascx.cs" Inherits="Folke.Code.Element.CommunityEditing" %>
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div class="content">
<asp:Label id="editingFeedback" runat="server" />
<dl>
<dt><%=Folke.Code.Texte.L("Name") %></dt><dd><asp:TextBox ID="name" runat="server" /><br />
<asp:RequiredFieldValidator ID="nameReq" runat="server" ControlToValidate="name" ErrorMessage="Community name is required!" /><br />
</dd>
</dl>
<asp:CheckBox ID="cbToggle" runat="server"
OnCheckedChanged="TogglePanel"
Text="Has a parent community" AutoPostBack="True" />
<asp:UpdatePanel ID="parentCommunityUpdatePanel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Panel id="parentCommunityPanel" runat="server" Visible="false">
<asp:DropDownList ID="communityListDropDownList" runat="server"/>
</asp:Panel>
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="cbToggle" />
</Triggers>
</asp:UpdatePanel>
<asp:Button runat="server" Text="Add" ID="send" onclick="send_Click" />
</div>
的后台代码很简单,因为它得到:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
// Populate drop down menu
var session = HibernateModule.CurrentSession;
var communityList = from community in session.Linq<Community>()
select community;
communityListDropDownList.DataValueField = "id";
communityListDropDownList.DataTextField = "name";
communityListDropDownList.DataSource = communityList;
communityListDropDownList.DataBind();
}
Response.Cache.SetCacheability(HttpCacheability.NoCache);
}
protected void TogglePanel(object sender, EventArgs e)
{
if (cbToggle.Checked)
{
parentCommunityPanel.Visible = true;
}
else
{
parentCommunityPanel.Visible = false;
}
}
因为这个工作正常在IE8中,我试图把一个非常相似的代码(几乎相同)在Web窗体,它在Firefox中运行得很好。既然上面的代码嵌入到MasterPage中,那么在Web Form中,然后是用户控件,所有这些“堆叠”都会导致问题?我花了几个小时,我找不到任何有意义的主角或解释。
编辑:
在检查的Firefox错误控制台,浏览器报告如下:
错误:theForm未定义 源文件:http://localhost:54003/EditCommunity.aspx 线:25
第25行是第一如果这个脚本语句如下:
<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['aspnetForm'];
if (!theForm) {
theForm = document.aspnetForm;
}
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
//]]>
</script>
我发现这个问题。在我的MasterPage中,标签被放置在部分内。表单标签必须位于页面的部分。
是的,你的高斯看起来是正确的ct ... 它看起来像多个脚本管理器causign的问题,尝试在页面上放置脚本管理器,而不是用户控制
将脚本管理器放在MasterPage中并没有解决Firefox中的问题。 – Astaar 2009-12-09 20:48:34
页面上有任何javascript错误吗? – 2009-12-09 20:29:14
你是对的,它的确如此。我编辑了这个问题来添加错误细节。 – Astaar 2009-12-09 20:44:13
对不起,不能给你一个正确的答案,但查看页面上的源代码,并检查你有在那里像