我在所有浏览器中都有一个下拉列表,但只有在IE11中,它在Autopostback = true时无效。
在这个论坛上搜索后,我发现在App_Browser文件夹中有一些文件需要更新,我还更新了但仍无法正常工作。我已经从这里更新了App_Browser文件
以下是代码:
Default7.aspx中的下拉列表
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack && !Page.IsCallback)
{
filldropdown1(ddl1);
}
}
public static void filldropdown1(DropDownList objDDL)
{
string strSql = "select DISTINCT(Roll_no),Roll_no from subject_details";
objDDL = FillingDDL(strSql, objDDL);
}
public static DropDownList FillingDDL(string strSql, DropDownList objCmb)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ToString());
if (con.State == ConnectionState.Closed)
{
con.Open();
}
SqlDataAdapter objDa = new SqlDataAdapter(strSql, con);
DataSet objDs = new DataSet();
try
{
objDa.Fill(objDs);
if (con.State == ConnectionState.Open)
{
con.Close();
}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
finally
{
objDa.Dispose();
if (con.State == ConnectionState.Open)
{
con.Close();
}
}
if (objDs.Tables[0].Rows.Count > 0)
{
objCmb.DataSource = objDs;
objCmb.DataTextField = objDs.Tables[0].Columns[1].ColumnName;
objCmb.DataValueField = objDs.Tables[0].Columns[0].ColumnName;
objCmb.DataBind();
}
//objCmb.Items.Insert(0, "Select here");
return objCmb;
}
<asp:DropDownList ID="ddl1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddl1_SelectedIndexChanged">
</asp:DropDownList></td>
in Default7.aspx.cs
protected void ddl1_SelectedIndexChanged(object sender, EventArgs e)
{
string ddl1value = ddl1.SelectedValue.ToString();
// fillDropdown2(ddl2, ddl1value);
string ddl2value = ddl2.SelectedValue.ToString();
// fillDropdown3(ddl3, ddl2value);
SqlConnection objConn2 = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
SqlCommand objCmd2;
SqlDataReader objRdr2;
// String strCmd2;
objConn2.Open();
objCmd2 = new SqlCommand("SELECT * FROM subject_details WHERE Roll_no = " +
"'" + ddl1value + "'", objConn2);
objRdr2 = objCmd2.ExecuteReader();
while (objRdr2.Read())
{
Label122.InnerText = (string)objRdr2["Name"].ToString().ToUpper();
Label12.InnerText = (string)objRdr2["Address"].ToString().ToUpper();
Label11.InnerText = (string)objRdr2["Address1"].ToString().ToUpper();
Label123.InnerText = (string)objRdr2["Address2"].ToString().ToUpper();
Label121.InnerText = (string)objRdr2["Address3"].ToString().ToUpper();
Label111.InnerText = (string)objRdr2["Address4"].ToString().ToUpper();
Label1.InnerText = (string)objRdr2["Address5"].ToString().ToUpper();
Label7.InnerText = (string)objRdr2["Address11"].ToString().ToUpper();
Label8.InnerText = (string)objRdr2["Address6"].ToString().ToUpper();
Label9.InnerText = (string)objRdr2["Address7"].ToString().ToUpper();
Label13.InnerText = (string)objRdr2["Address8"].ToString().ToUpper();
Label14.InnerText = (string)objRdr2["Address9"].ToString().ToUpper();
Label15.InnerText = (string)objRdr2["Address10"].ToString().ToUpper();
}
if (ddl1value == "Other")
{
lbl2.Visible = true;
TextBox2.Visible = true;
}
else
{
lbl2.Visible = false;
TextBox2.Visible = false;
}
objRdr2.Close();
objConn2.Close();
}
欢迎提供任何帮助
答案 0 :(得分:0)
尝试使用Javascript或JQuery刷新Drop Down 你有没有在另一个版本的IE中检查这个
$(document).ready(function(){
$("#dropDownId").change(function(){
window.location.reload(true);
});
});
答案 1 :(得分:0)
最后在这个论坛中搜索足够我通过更新App_Browser文件夹的ie.browser中的代码获得了解决方案...我使用了以下代码...
<browsers>
<browser id="IE11" parentID="Mozilla">
<identification>
<userAgent match="Trident\/7.0; rv:(?'version'(?'major'\d+)(\.(?'minor'\d+)?)(?'letters'\w*))(?'extra'[^)]*)" />
<userAgent nonMatch="IEMobile" />
</identification>
<capture>
<userAgent match="Trident/(?'layoutVersion'\d+)" />
</capture>
<capabilities>
<capability name="browser" value="IE" />
<capability name="layoutEngine" value="Trident" />
<capability name="layoutEngineVersion" value="${layoutVersion}" />
<capability name="extra" value="${extra}" />
<capability name="isColor" value="true" />
<capability name="letters" value="${letters}" />
<capability name="majorversion" value="${major}" />
<capability name="minorversion" value="${minor}" />
<capability name="screenBitDepth" value="8" />
<capability name="type" value="IE${major}" />
<capability name="version" value="${version}" />
</capabilities>
</browser>
<!-- Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11,0) like Gecko -->
<browser id="IE110" parentID="IE11">
<identification>
<capability name="majorversion" match="11" />
</identification>
<capabilities>
<capability name="ecmascriptversion" value="3.0" />
<capability name="jscriptversion" value="5.6" />
<capability name="javascript" value="true" />
<capability name="javascriptversion" value="1.5" />
<capability name="msdomversion" value="${majorversion}.${minorversion}" />
<capability name="w3cdomversion" value="1.0" />
<capability name="ExchangeOmaSupported" value="true" />
<capability name="activexcontrols" value="true" />
<capability name="backgroundsounds" value="true" />
<capability name="cookies" value="true" />
<capability name="frames" value="true" />
<capability name="javaapplets" value="true" />
<capability name="supportsCallback" value="true" />
<capability name="supportsFileUpload" value="true" />
<capability name="supportsMultilineTextBoxDisplay" value="true" />
<capability name="supportsMaintainScrollPositionOnPostback" value="true" />
<capability name="supportsVCard" value="true" />
<capability name="supportsXmlHttp" value="true" />
<capability name="tables" value="true" />
<capability name="supportsAccessKeyAttribute" value="true" />
<capability name="tagwriter" value="System.Web.UI.HtmlTextWriter" />
<capability name="vbscript" value="true" />
</capabilities>
</browser>
</browsers>