Wednesday, March 21, 2012

DropDownList becomes disabled during asynch postback

The basic issue I find on my asynch postback is that two of myDropDownList controls becomes disabled during asynch postback. Once thepostback has completed I get access again to the DropDownList.

Nowmy two DropDown are in fact located within the UpdatePanel control, sonaturally it has something to do with that. Maybe its theautopostbacl=true property ?

Here are some details of my aspx Master page :

<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1"runat="server"></asp:ScriptManager> <!-- note:ScriptMngr/Timer must be within form tag -->

<asp:Timer ID="TimerOrders" runat="server" Interval="5000" />
<div >
<asp:UpdatePanel ID="UpdateTally" runat="server" >
<ContentTemplate>


<asp:DropDownList ID="drpFilterList"DataSourceID="ObjectDataSourceFilterList" DataValueField="filter_id"DataTextField="f_name" AppendDataBoundItems="true" runat="server"Width="81px" AutoPostBack="True"OnSelectedIndexChanged="drpFilterList_SelectedIndexChanged"EnableViewState="true" >
<asp:ListItem Selected="True" Text="Default" Value="0" />
</asp:DropDownList>

<asp:DropDownList ID="DrpStatusList"DataSourceID="ObjectDataSourceStatusList" MaxLength="30" Width="110px"AutoPostBack="True" DataTextField="status" DataValueField="status"AppendDataBoundItems="true" runat="server"OnSelectedIndexChanged="DrpStatusList_SelectedIndexChanged" >
<asp:ListItem Value="0" Selected="true">All</asp:ListItem>
<asp:ListItem Value="LiveOrders"Selected="False">LiveOrders</asp:ListItem>
</asp:DropDownList>

</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="TimerOrders"EventName=""/>
</Triggers>

</asp:UpdatePanel

I am facing a similar issue. Please do let me know if you find a solution!!!


Hi,robertmazzo

I test it with this demo,It works,I don't have your problem:

<%@. 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 drpFilterList_SelectedIndexChanged(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(3000);
Label1.Text = ((DropDownList)sender).SelectedItem.Value + "--" + DateTime.Now.ToString();
}

protected void DrpStatusList_SelectedIndexChanged(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(3000);
Label1.Text = ((DropDownList)sender).SelectedItem.Value + "--" + DateTime.Now.ToString();
}

protected void TimerOrders_Tick(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(3000);
Label1.Text = DateTime.Now.ToString();
}
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:Timer ID="TimerOrders" runat="server" Interval="5000" OnTick="TimerOrders_Tick" />
<div>
<asp:UpdatePanel ID="UpdateTally" runat="server">
<ContentTemplate>
<asp:DropDownList ID="drpFilterList" runat="server" Width="81px" AutoPostBack="True" OnSelectedIndexChanged="drpFilterList_SelectedIndexChanged" EnableViewState="true">
<asp:ListItem Selected="True" Text="Default" Value="0" />
<asp:ListItem Value="test" Selected="False">test</asp:ListItem>
</asp:DropDownList>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:DropDownList ID="DrpStatusList" Width="110px" AutoPostBack="True" runat="server" OnSelectedIndexChanged="DrpStatusList_SelectedIndexChanged" EnableViewState="true">
<asp:ListItem Value="0" Selected="true">All</asp:ListItem>
<asp:ListItem Value="LiveOrders" Selected="False">LiveOrders</asp:ListItem>
</asp:DropDownList>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="TimerOrders" />
</Triggers>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>

Let me know if you need more info.

If this help you,don't forget mark it as a answer.Thanks!


Thanks for testing. I actually copied your page into a brand new page in my project and I face a similiar issue.

Ifyou select one of the DropDowns to display the list and keep your mousein place without clicking, then you should see the DropDown reset. Atthat point you need to reselect the DropDown with the mouse in order tosee the list again.

Inmy specific case (perhaps it has to dowith my master page) , the dropdown list sometimes remains displayedwhen I clickbut I cannot actually select a value for a couple of seconds. At timesI also notice that the DropDown values are cleared and I have toreselect the list (as previously mentioned).

I know users are going to complain about this because my inhouse QA tester is already noticing it.

Thank you again,

Bob


If you select one of the DropDowns to display the list and keep your mouse in place without clicking, then you should see the DropDown reset. At that point you need to reselect the DropDown with the mouse in order to see the list again. ?????

I do it just now! Haven't your problem!

You may update your IE to 7.0?


ThanksJin-Yu Yin - MSFT , your code working perfectly..

I also have IE 7


Is this is a known issue in IE6??


Okay, all you need to really do is suggest that I check myversion of IE. All the extra "?" and "!" characters are really notnecessary.

I actually have IE 7.0 on my machine. I'll test it somewhere else.

thank you for helping.

Bob


If you have time please copy this code onto your machine.

<>Here's my aspx code for Default2.aspx :

<%@. Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>THIS IS ONLY A DROPDOWNLIST TEST PAGE !!!</title>
</head>
<body>
<form id="form1" runat="server">

<asp:ScriptManagerID="ScriptManager1" runat="server"/>
<asp:TimerID="TimerOrders" runat="server" Interval="4000"OnTick="TimerOrders_Tick" />

<div
<asp:UpdatePanel ID="UpdateTally" runat="server">
<ContentTemplate>
<asp:DropDownList ID="drpFilterList" runat="server" Width="81px"AutoPostBack="True"OnSelectedIndexChanged="drpFilterList_SelectedIndexChanged"EnableViewState="true">
<asp:ListItem Selected="True" Text="Default" Value="0" />
<asp:ListItem Value="test"Selected="False">test</asp:ListItem>
</asp:DropDownList>
<asp:Label ID="Label1" runat="server"Text="Label"></asp:Label>
<asp:DropDownList ID="DrpStatusList" Width="110px"AutoPostBack="True" runat="server"OnSelectedIndexChanged="DrpStatusList_SelectedIndexChanged"EnableViewState="true">
<asp:ListItem Value="0" Selected="true">All</asp:ListItem>
<asp:ListItem Value="LiveOrders"Selected="False">LiveOrders</asp:ListItem>
<asp:ListItem Value="New Order" >New Order</asp:ListItem>
<asp:ListItem Value="Cancelled">Cancelled</asp:ListItem>
</asp:DropDownList>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="TimerOrders" />
</Triggers>
</asp:UpdatePanel>

</div>
</form>
</body>
</html>

Here's the .aspx.cs code :

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}

protected void drpFilterList_SelectedIndexChanged(object sender, EventArgs e)
{
//System.Threading.Thread.Sleep(3000);
Label1.Text =((DropDownList)sender).SelectedItem.Value + "--" +DateTime.Now.ToString();
}

protected void DrpStatusList_SelectedIndexChanged(object sender, EventArgs e)
{
//System.Threading.Thread.Sleep(3000);
Label1.Text =((DropDownList)sender).SelectedItem.Value + "--" +DateTime.Now.ToString();
}

protected void TimerOrders_Tick(object sender, EventArgs e)
{
//System.Threading.Thread.Sleep(3000);
Label1.Text = DateTime.Now.ToString();
}
}

--------------------------

No comments:

Post a Comment