asp.net AJAX Advance Tips & Tricks (9)

Source: Internet
Author: User

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>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.