PDA

View Full Version : ComboBox and UpdatePanel



Timothy
Sep 01, 2008, 12:32 PM
Hello,

I know you're working on the UpdatePanel fixes; here is another scenario I just encountered:

Example.aspx


<%@ Page Language="C#" %>
<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>

<!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_Init(object sender, EventArgs e)
{
Control control = Page.LoadControl("Example-UserControl.ascx");

UserControl.Controls.Add(control);
}
protected void Page_Load(object sender, EventArgs e)
{

}
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager runat="server" EnablePartialRendering="True" />
<ext:ScriptManager runat="server" ScriptMode="Debug" />
<asp:UpdatePanel runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:PlaceHolder ID="UserControl" runat="server" />
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
</html>



Example-UserControl.ascx


<%@ Control Language="C#" ClassName="Example_UserControl" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
BindCountries();
}

public void BindCountries()
{
Countries.DataSource = new object[]
{
new object[]{"AL", "Alabama", "The Heart of Dixie"},
new object[] {"AK", "Alaska", "The Land of the Midnight Sun"},
new object[] {"AZ", "Arizona", "The Grand Canyon State"},
new object[] {"AR", "Arkansas", "The Natural State"},
new object[] {"CA", "California", "The Golden State"},
new object[] {"CO", "Colorado", "The Mountain State"},
new object[] {"CT", "Connecticut", "The Constitution State"},
new object[] {"DE", "Delaware", "The First State"},
new object[] {"DC", "District of Columbia", "The Nation's Capital"},
new object[] {"FL", "Florida", "The Sunshine State"},
new object[] {"GA", "Georgia", "The Peach State"},
new object[] {"HI", "Hawaii", "The Aloha State"},
new object[] {"ID", "Idaho", "Famous Potatoes"},
new object[] {"IL", "Illinois", "The Prairie State"},
new object[] {"IN", "Indiana", "The Hospitality State"},
new object[] {"IA", "Iowa", "The Corn State"},
new object[] {"KS", "Kansas", "The Sunflower State"},
new object[] {"KY", "Kentucky", "The Bluegrass State"},
new object[] {"LA", "Louisiana", "The Bayou State"},
new object[] {"ME", "Maine", "The Pine Tree State"},
new object[] {"MD", "Maryland", "Chesapeake State"},
new object[] {"MA", "Massachusetts", "The Spirit of America"},
new object[] {"MI", "Michigan", "Great Lakes State"},
new object[] {"MN", "Minnesota", "North Star State"},
new object[] {"MS", "Mississippi", "Magnolia State"},
new object[] {"MO", "Missouri", "Show Me State"},
new object[] {"MT", "Montana", "Big Sky Country"},
new object[] {"NE", "Nebraska", "Beef State"},
new object[] {"NV", "Nevada", "Silver State"},
new object[] {"NH", "New Hampshire", "Granite State"},
new object[] {"NJ", "New Jersey", "Garden State"},
new object[] {"NM", "New Mexico", "Land of Enchantment"},
new object[] {"NY", "New York", "Empire State"},
new object[] {"NC", "North Carolina", "First in Freedom"},
new object[] {"ND", "North Dakota", "Peace Garden State"},
new object[] {"OH", "Ohio", "The Heart of it All"},
new object[] {"OK", "Oklahoma", "Oklahoma is OK"},
new object[] {"OR", "Oregon", "Pacific Wonderland"},
new object[] {"PA", "Pennsylvania", "Keystone State"},
new object[] {"RI", "Rhode Island", "Ocean State"},
new object[] {"SC", "South Carolina", "Nothing Could be Finer"},
new object[] {"SD", "South Dakota", "Great Faces, Great Places"},
new object[] {"TN", "Tennessee", "Volunteer State"},
new object[] {"TX", "Texas", "Lone Star State"},
new object[] {"UT", "Utah", "Salt Lake State"},
new object[] {"VT", "Vermont", "Green Mountain State"},
new object[] {"VA", "Virginia", "Mother of States"},
new object[] {"WA", "Washington", "Green Tree State"},
new object[] {"WV", "West Virginia", "Mountain State"},
new object[] {"WI", "Wisconsin", "America's Dairyland"},
new object[] {"WY", "Wyoming", "Like No Place on Earth"}
};

Countries.DataBind();
}

protected void drpCountry_ItemChanged(object sender, EventArgs e)
{
lblSelected.Text = "Selected: " + drpCountry.SelectedItem.Value;
}
</script>

<ExtJS:Store ID="Countries" runat="server" AutoLoad="True">
<Reader>
<ExtJS:ArrayReader ReaderID="Abbrev">
<Fields>
<ExtJS:RecordField Name="Abbrev" />
<ExtJS:RecordField Name="DisplayName" />
<ExtJS:RecordField Name="Description" />
</Fields>
</ExtJS:ArrayReader>
</Reader>
</ExtJS:Store>
<ExtJS:ComboBox ID="drpCountry" runat="server" AutoPostBack="True" OnItemChanged="drpCountry_ItemChanged" StoreID="Countries" DisplayField="DisplayName" ValueField="Abbrev" Editable="False" EmptyText="----" ForceSelection="True" Mode="Local" TypeAhead="False" Select&#111;nfocus="True" Stateful="True" TriggerAction="All" Width="255" />
<asp:RequiredFieldValidator runat="server" ControlToValidate="drpCountry" ErrorMessage="Country is a required field" ValidationGroup="vsCustomer" Display="Dynamic">!</asp:RequiredFieldValidator>
<asp:Label ID="lblSelected" runat="server" />



Fails in both IE6 and FF3.0 -- ComboBox disappears

Cheers,
Timothy

geoffrey.mcgill
Sep 01, 2008, 8:18 PM
Once revisions to the <asp:UpdatePanel> support are complete, I'll update this thread. What you're doing should work. I think ;)

Timothy
Sep 01, 2008, 11:27 PM
Sorry, I'm being a pain but trying every scenario, better for you because I'm giving it a thorough work out -- I'm a big user control user ;)

Cheers,
Timothy