2015-09-04 51 views
0

我目前正在使用下拉列表動態加載數據的網頁上工作。Firefox中的ASP下拉列表

如果我從下拉列表中選擇一個項目,直接加載數據後,我立即嘗試選擇一個不同的項目(就像我第一次錯過點擊),沒有任何反應。如果我再次點擊,它工作正常。

如果我選擇一個項目,點擊其他任何地方,然後嘗試再次選擇一個不同的項目,它也可以正常工作。

此問題不會在Chrome或IE或火狐早V33

這裏是我的代碼的基本功能以及它是如何做的Firefox版本出現。請注意,前兩次我選擇一個菜單項目工作正常,只有在第三次問題開始發生。

protected void ddlstMonitor_SelectedIndexChanged(object sender, EventArgs e) 
{ 
if (ddlstRole.SelectedIndex >= 0 && ddlstMonitor.SelectedValue != "-None-" && ddlstRole.SelectedValue != "-None-") 
{ 
    loadconfig(ddlstRole.SelectedValue, ddlstMonitor.SelectedValue); 
} 
else 
{ 
    for (int x = 1; x <= count; x++) //hides all the controls made visible by the previous selection 
    { 
    ((Label)pnlConfig.FindControl("Label" + x.ToString())).Visible = false; 
    ((TextBox)pnlConfig.FindControl("TextBox" + x.ToString())).Visible = false; 
    } 
    btnSave.Visible = true; 
    conf1.Visible = true; 
    val1.Visible = true; 
    lblConfig.Text = "Please select a Monitor for the configuration settings to be loaded."; 
} 
lbl23.Text = "0"; 
} 

而loadconfig()會執行以下操作。

using (SqlConnection sqlConnection = new SqlConnection(dataBase)) 
    { 
    sqlConnection.Open(); 
    try 
    { 
     SqlCommand sqlCommand; 
     SqlDataReader sqlDataReader; 

     //open the connection 


     //setup command 
     sqlCommand = sqlConnection.CreateCommand(); 
     sqlCommand.Connection = sqlConnection; 
     sqlCommand.CommandType = System.Data.CommandType.StoredProcedure; 
     sqlCommand.Parameters.Clear(); 
     sqlCommand.CommandText = query; 

    //Parameters are added using the drop-down menu's selected items 

     //execute the query 
     sqlDataReader = sqlCommand.ExecuteReader(); 
     lstType = new List<string> { }; 
     for (int x = 1; x <= count; x++) //all the relevant previously visible controls are made invisible 
     { 
     ((Label)pnlConfig.FindControl("Label" + x.ToString())).Visible = false; 
     ((TextBox)pnlConfig.FindControl("TextBox" + x.ToString())).Visible = false; 
     } 
     if (sqlDataReader.HasRows) 
     { 
     int i = 1; 
     count = 1; 

     while (sqlDataReader.Read()) //The controls are loaded with new values. 
     { 
     ((TextBox)pnlConfig.FindControl("TextBox" + i.ToString())).Attributes["TextChanged"] = "TextBox1_TextChanged"; 

      ((TextBox)pnlConfig.FindControl("TextBox" + i.ToString())).TextMode = TextBoxMode.SingleLine; 
      ((Label)pnlConfig.FindControl("Label" + i.ToString())).Text = (string)sqlDataReader["CONFIGDESC"]; 
      ((Label)pnlConfig.FindControl("Label" + i.ToString())).Visible = true;    

      ((TextBox)pnlConfig.FindControl("TextBox" + i.ToString())).Text = (string)sqlDataReader["CUSTOMCONFIGVALUE"]; 
      ((TextBox)pnlConfig.FindControl("TextBox" + i.ToString())).Visible = true; 



      ((Label)pnlConfig.FindControl("lbl" + i.ToString())).Text = (string)sqlDataReader["VALUEVARIABLE"]; 
      i++; 
      count++; 
     } 
     lblConfig.Text = ""; 
     btnSave.Visible = true;    
     ((TextBox)pnlConfig.FindControl("TextBox1")).Focus(); 
     } 
     sqlConnection.Close(); 
    } 
catch 
    { 
     sqlConnection.Close(); 
     lblResut.Visible = true; 
     lblResut.Text = "An error has occurred; unable to load configuration."; 
     for (int x = 1; x <= (count + 1); x++) 
     { 
     ((Label)pnlConfig.FindControl("Label" + x.ToString())).Visible = false; 
     ((TextBox)pnlConfig.FindControl("TextBox" + x.ToString())).Visible = false; 
     } 
    } 
    } 

這裏是下拉列表

<asp:DropDownList ID="ddlstMonitor" runat="server" 
AppendDataBoundItems="True" AutoPostBack="True" 
onselectedindexchanged="ddlstMonitor_SelectedIndexChanged" TabIndex="2"> 
<asp:ListItem>-None-</asp:ListItem> 
</asp:DropDownList> 
+1

請提供您到目前爲止的代碼。 – albert

+0

你到目前爲止嘗試過什麼?還張貼一些代碼。如果你發佈一些與之相關的代碼,想象就變得容易了。 – BNN

+0

我想也許是因爲在再次選擇一個項目之前點擊其他任何東西似乎可以解決這個問題,即將焦點設置爲各種對象都可以工作。它沒有。然後,我嘗試禁用並選擇一個項目後啓用列表。它也沒有工作。 Firefox建議在沒有插件的情況下以安全模式運行,並從about:support菜單重新啓動瀏覽器。這也沒有做任何事 我試圖改變數據加載的方式,但是也沒有改變任何東西。 –

回答

0

在沒有看到代碼,我傾向於對一些項目我看到發生這種情況時指出(形式基本上無法使用期限)。它們是否在UpdatePanel中運行,並因此導致它們全部被綁定?有時,「指引」用戶點擊可見的地方是一個解決方案。有時候需要確保一個selectedindexchanged事件只加載一件事情,有時你可能必須讓db管理器調整一個查詢,並確保你沒有加載具有3秒數據拉取功能的dropdownbox。

但是從UpdatePanel開始。

+0

它似乎並沒有被使用。這也不會影響它在IE中嗎? –