Eyeball
TechnoChill.com

VS 2008 UpdatePanel control event not firing

A drop down list placed in an asp.net update panel will not execute the server side SelectedIndexChanged. In fact, the only server side events that will fire are the OnLoad and Onprerender. From

 

From Advanced ASP.NET AJAX Server Controls For .NET Framework 3.5

"When the server processes the partial postback request, the page and controls are processed just as if we had initiated a normal postback. What this boils down to is that during a partial postback, the page's controls will be performing the same steps they did when our page was first created, essentially re-creating the controls from scratch again. The fact that all controls are reprocessed just as they were on the page's first load is an important consideration because, as you will see later in this chapter, some of our development practices that would work fine during a complete page refresh will not work anymore."

 

Each time the Dropdownlist posts back to the server, the server processes it like the initial page load. The SelectedIndex will be -1 and the controls id's and text collection empty.

 

The SelectedIndex event never fires in the following code because the drop down boxes are inside the refreshing update panel .

 

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="AuxControl.ascx.cs" Inherits="AuxControl" %>

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"

ChildrenAsTriggers="False" EnableViewState="False">

<ContentTemplate>

<asp:ScriptManagerProxy ID="ScriptManagerProxy2" runat="server"

EnableViewState="False">

</asp:ScriptManagerProxy>

<asp:Label ID="Label2" runat="server" Text="Battle Field: "></asp:Label>

<asp:DropDownList ID="BattleFieldList" runat="server"

onload="BattleFieldList_Load"

onselectedindexchanged="BattleFieldList_SelectedIndexChanged"

AutoPostBack="True" onprerender="BattleFieldList_PreRender"

EnableViewState="False" >

</asp:DropDownList>

<br />

<asp:Label ID="Label3" runat="server" Text="Web Cam: "></asp:Label>

<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" EnableViewState="False"

onload="DropDownList1_Load" onprerender="DropDownList1_PreRender"

onselectedindexchanged="DropDownList1_SelectedIndexChanged">

</asp:DropDownList>

</ContentTemplate>

<Triggers>

<asp:AsyncPostBackTrigger ControlID="BattleFieldList"

EventName="SelectedIndexChanged" />

<asp:AsyncPostBackTrigger ControlID="DropDownList1"

EventName="SelectedIndexChanged" />

</Triggers>

</asp:UpdatePanel>

 

 

 

 

 

 

DISCLAIMER: It is assumed that users are familiar with the operating system they are using and comfortable with making the suggested changes. PcCare.com will not be held responsible if changes you make cause a system failure.

Please review our Terms of Service and Privacy statement before initiating service or using this site. Microsoft® is a registered trademark of Microsoft Corporation in the United States and/or other countries. Epicor® is a registered trademark of Epicor Software Corporation. Site Map. About Us

TechnoChill.com is owned and operated by TechnoChill Inc.