2009-12-09 90 views
-1

我試圖做一些聽起來相當簡單的使用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> 
+1

頁面上有任何javascript錯誤嗎? – 2009-12-09 20:29:14

+0

你是對的,它的確如此。我編輯了這個問題來添加錯誤細節。 – Astaar 2009-12-09 20:44:13

+0

對不起,不能給你一個正確的答案,但查看頁面上的源代碼,並檢查你有在那裏像

。如果document.forms ['aspnetForm']返回'undefined',那麼標記中可能會出現錯誤。 – 2009-12-09 21:01:17

回答

0

我發現這個問題。在我的MasterPage中,標籤被放置在部分內。表單標籤必須位於頁面的部分。

0

是的,你的高斯看起來是正確的ct ... 它看起來像多個腳本管理器causign的問題,嘗試在頁面上放置腳本管理器,而不是用戶控制

+0

將腳本管理器放在MasterPage中並沒有解決Firefox中的問題。 – Astaar 2009-12-09 20:48:34