我目前正在使用下拉列表動態加載數據的網頁上工作。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>
請提供您到目前爲止的代碼。 – albert
你到目前爲止嘗試過什麼?還張貼一些代碼。如果你發佈一些與之相關的代碼,想象就變得容易了。 – BNN
我想也許是因爲在再次選擇一個項目之前點擊其他任何東西似乎可以解決這個問題,即將焦點設置爲各種對象都可以工作。它沒有。然後,我嘗試禁用並選擇一個項目後啓用列表。它也沒有工作。 Firefox建議在沒有插件的情況下以安全模式運行,並從about:support菜單重新啓動瀏覽器。這也沒有做任何事 我試圖改變數據加載的方式,但是也沒有改變任何東西。 –