Hi,
I have an application that has two DropDownLists on a page. The first is just a plain ASP DropDownList; the second is an ASP DropDownList inside an UpdatePanel. The page also contains a label inside a second UpdatePanel.
When the item in the first DropDownList is changed, the second DropDownList is populated. When the item in the second DropDownList is changed, the Label's text is changed.
I have noticed that when the first DropDownList changes, the second DropDownList "flickers" as it populates. When I select a value in the second list, the label updates as it should, but the second DropDownList again flickers, as if it is also being refreshed. Both UpdatePanels have UpdateMode="conditional" set.
My question is whether this is normal behavior on the second DropDownList, since it is inside an UpdatePanel, or do I have something set wrong? It's a minor issue, but kind of annoying since I would not expect to see any kind of refresh when changing a value in the second DropDownList.
I have included a simple example which shows what I'm talking about. Thanks as always for your help!
<%@dotnet.itags.org.PageLanguage="vb"AutoEventWireup="false"CodeBehind="Default.aspx.vb"Inherits="DropDownTest._Default" %>
<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
<title>Untitled Page</title></head>
<body>
<formid="form1"runat="server">
<asp:ScriptManagerID="ScriptManager1"runat="server"/>
<div>
<ASP:DROPDOWNLISTid="DropDownList1"autopostback="true"runat="server"width="110px"></ASP:DROPDOWNLIST>
<br/><br/><br/><br/><br/><br/>
<ASP:UPDATEPANELid="UpdatePanel1"runat="server"updatemode="conditional">
<CONTENTTEMPLATE>
<ASP:DROPDOWNLISTid="DropDownList2"autopostback="true"runat="server"width="110px"></ASP:DROPDOWNLIST>
</CONTENTTEMPLATE>
<TRIGGERS>
<ASP:ASYNCPOSTBACKTRIGGERcontrolid="DropDownList1"eventname="SelectedIndexChanged"/>
</TRIGGERS>
</ASP:UPDATEPANEL>
<br/><br/><br/><br/><br/><br/>
<ASP:UPDATEPANELid="UpdatePanel2"runat="server"updatemode="conditional">
<CONTENTTEMPLATE>
<ASP:LABELid="Label1"runat="server"text="Label"></ASP:LABEL>
</CONTENTTEMPLATE>
<TRIGGERS>
<ASP:ASYNCPOSTBACKTRIGGERcontrolid="DropDownList2"eventname="SelectedIndexChanged"/>
</TRIGGERS>
</ASP:UPDATEPANEL>
</div>
</form></body>
</html>
PartialPublicClass _Default
Inherits System.Web.UI.Page
ProtectedSub Page_Load(ByVal senderAsObject,ByVal eAs System.EventArgs)HandlesMe.LoadIfNot IsPostBackThen
Me.DropDownList1.Items.Clear()Dim objListItemAs ListItem
objListItem =New ListItemobjListItem.Text = 1
Me.DropDownList1.Items.Add(objListItem)objListItem =New ListItemobjListItem.Text = 2
Me.DropDownList1.Items.Add(objListItem)
objListItem =New ListItemobjListItem.Text = 3
Me.DropDownList1.Items.Add(objListItem)EndIf
EndSub
PrivateSub DropDownList1_SelectedIndexChanged(ByVal senderAsObject,ByVal eAs System.EventArgs)Handles DropDownList1.SelectedIndexChangedMe.DropDownList2.Items.Clear()
Dim objListItemAs ListItemobjListItem =New ListItemobjListItem.Text = 9
Me.DropDownList2.Items.Add(objListItem)
objListItem =New ListItemobjListItem.Text = 8
Me.DropDownList2.Items.Add(objListItem)objListItem =New ListItemobjListItem.Text = 7
Me.DropDownList2.Items.Add(objListItem)
EndSubPrivateSub DropDownList2_SelectedIndexChanged(ByVal senderAsObject,ByVal eAs System.EventArgs)Handles DropDownList2.SelectedIndexChanged
Me.Label1.Text =Me.DropDownList1.SelectedValue +Me.DropDownList2.SelectedValue
EndSubEndClass
Does this happen in both FF and IE6/7?
Definitely in IE6, as that's my default right now. I tried Firefox, and it does not seem to have this issue.
I also noticed that in IE6, when I select the item in the first list, the item is highlighted (dark blue background) until I move focus. When I select an item in the second list, the highlighting is removed. This could simply be because the focus shifted to the label. Neither list stays highlighted in Firefox.
So, it appears that it may be an IE quirk. Has anyone else seen this issue or found a work around? I should be getting IE7 on my PC in the next week or two, so maybe that will solve it!
IE6 blows. I know - Shocking news!
Try it out on IE7 and see if that fixes your problem.
I realize that some of the world is still using IE6, some can't even upgrade to 7 (ie. Win2K users) but I hate coding for that browser.
You should set the property of the UpdatePanel named "UpdatePanel2":updatemode="all"
No comments:
Post a Comment