DropDownList the strange Phenomena and solutions under Firefox-whose bugs?
Objective:
Today in ASP.net forum encountered a strange problem, a seemingly very simple demo in IE and other browsers in the normal operation, but in Firefox but caused a strange problem, so that the page of the DropDownList dead, after research, finally found A solution, but the question of whose bugs are still unknown.
Problem Recurrence:
A ScriptManager
A DropDownList
A UpdatePanel, with a button inside.
Use Scriptmanager.registerstartupscript to output a window.alert in a button click event
OK, easy enough?! The code is as follows:
<%@ Page language= "C #"%>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<script runat= "Server" >
protected void Page_Load (object sender, EventArgs e) {}
protected void Button1_Click (object sender, EventArgs e)
{
Scriptmanager.registerstartupscript (this. Button2, Button2.gettype (), "Codealert", "alert (' kao! ');", true);
Button2.text = "Updated" + DateTime.Now.ToString ();
}
</script>
<title></title>
<body>
<form id= "Form1" runat= "Server" >
<div>
<asp:scriptmanager id= "ScriptManager1" runat= "Server" >
</asp:ScriptManager>
</div>
<asp:dropdownlist id= "DropDownList1" runat= "Server" >
<asp:ListItem>Text1</asp:ListItem>
<asp:ListItem>Text2</asp:ListItem>
<asp:ListItem>Text3</asp:ListItem>
<asp:ListItem>Text4</asp:ListItem>
<asp:ListItem>Text5</asp:ListItem>
</asp:DropDownList>
<asp:updatepanel id= "UpdatePanel1" runat= "Server" >
<ContentTemplate>
<asp:button id= "Button2" runat= "Server" text= "button" onclick= "Button1_Click"/>
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>