UpdatePanel doesn't work after using ModalPopupExtender and validation control

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I have found out a problem with UpdatePanel when using asp.net validation control and Ajax toolkit ModalPopupExtender control.

After RequiredFieldValidator and ModalPopupExtender are showed, the postback event in UpdatePanel will not be fired when I select a drop down list which was set autopostback=true before. You can try these lines of code below.
<span style="font-size:small <span style="font-size:small
Click on Show button and then try selecting a value from the drop down list, the post back will not be rasied inside UpdatePanel

<pre class="prettyprint <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>

<!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></title>

</head>
<body>

<form id="form1" runat="server
<asp:ScriptManager ID="ScriptManager1" runat="server
</asp:ScriptManager>


<asp:UpdatePanel runat="server" ID="updateTest" UpdateMode="Conditional" >
<ContentTemplate>
<asp:DropDownList runat="server" ID="ddlProvince" AutoPostBack="true"
onselectedindexchanged="ddlProvince_SelectedIndexChanged
<asp:ListItem Text="HN" Value="HN </asp:ListItem>
<asp:ListItem Text="BN" Value="BN </asp:ListItem>
</asp:DropDownList>
<br />
<asp:Label runat="server" ID="lblSelectedProvince </asp:Label>

<br />
<asp:TextBox runat="server" ID="txtName </asp:TextBox>
<br />
<asp:Button ID="fakeHidden" runat="server" Text="Show" />
<ajaxToolkit:ModalPopupExtender ID="popupErrMsg" runat="server" TargetControlID="fakeHidden"
PopupControlID="SummaryDiv" BackgroundCssClass="modalBg" CancelControlID="btnOk" />
<div id="SummaryDiv" class="popupdiv" style="display: none; border:1px solid black
<asp:Button CssClass="DefaultButton" ID="btnOk" runat="server" Text="Close" CausesValidation="false" />

<asp:RequiredFieldValidator SetFocusOnError="true" ID="ValidatorBillingFirstNameRequired"
Display="None" runat="server" ControlToValidate="txtName" />
</ContentTemplate>
</asp:UpdatePanel>


</form>



</body>
</html>
[/code]
<span style="color:#0000ff; font-size:small <span style="color:#0000ff; font-size:small <span style="color:#0000ff; font-size:small Could some one help me to resolve this problem? I spent lots of time on investigating but havent resolved it yet.

Thanks
<span style="color:#0000ff; font-size:small <span style="color:#0000ff; font-size:small <span style="color:#0000ff; font-size:small <br/>
<span style="font-size:small <span style="font-size:small

View the full article
 
Back
Top