我正在使用更新面板。这里我必须在某些条件与下拉值选择匹配时动态启用正则表达式验证器。
这是我的设计:
<asp:UpdatePanel ID="UpdatePanel20" runat="server">
<ContentTemplate>
<asp:Panel ID="Panel_Search" runat="server" Width="100px" DefaultButton="btnsearch">
<table>
<tr>
<td>
<asp:UpdatePanel ID="UpdatePanel15" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:DropDownList ID="DDL_Column_List" runat="server"
AppendDataBoundItems="true" Width="120px" ValidationGroup="Search" AutoPostBack="True">
<asp:ListItem Value="-1">Select Column</asp:ListItem>
</asp:DropDownList>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="DDL_Column_List"
EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
</td>
<td> </td>
<td><asp:TextBox ID="txtsearch" runat="server" CssClass="input"
ValidationGroup="Search"></asp:TextBox>
<asp:RegularExpressionValidator id="RegularExpressionValidator5" runat="server"
ValidationGroup="Search"
SetFocusOnError="true" ControlToValidate="txtsearch"
ValidationExpression="^(((0[1-9]|[12]\d|3[01])\/(0[13578]|1[02])\/((19|[2-9]\d)\d{2}))|((0[1-9]|[12]\d|30)\/(0[13456789]|1[012])\/((19|[2-9]\d)\d{2}))|((0[1-9]|1\d|2[0-8])\/02\/((19|[2-9]\d)\d{2}))|(29\/02\/((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))))$"
Display="None" Enabled="False"></asp:RegularExpressionValidator>
<ajaxToolkit:ValidatorCalloutExtender ID="ValidatorCalloutExtender20" runat="server" TargetControlID="RegularExpressionValidator5" WarningIconImageUrl="~/images/Warning.gif" CloseImageUrl="~/images/close.gif" >
</ajaxToolkit:ValidatorCalloutExtender>
</td>
<td><asp:Button ID="btnsearch" runat="server" Text="Search" CssClass="button"
onclick="btnsearch_Click" ValidationGroup="Search"/></td>
</tr></table>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
以下是基于下拉列表选择启用正则表达式验证器的方法。
protected void DDL_Column_List_SelectedIndexChanged(object sender, System.EventArgs e)
{
if (DDL_Column_List.SelectedItem.Value.Equals("19"))
{
RegularExpressionValidator5.Enabled = true;
RegularExpressionValidator5.ErrorMessage = "Register date format should be like: DD/MM/yyyy";
UpdatePanel20.Update();
MPE.Show();
}
}
如何加载此页面然后发生一次运行时错误,如:
Server Error in '/CRM' Application.
An extender can't be in a different UpdatePanel than the control it extends.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: An extender can't be in a different UpdatePanel than the control it extends.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[InvalidOperationException: An extender can't be in a different UpdatePanel than the control it extends.]
System.Web.UI.ExtenderControl.RegisterWithScriptManager() +443813
System.Web.UI.ExtenderControl.OnPreRender(EventArgs e) +19
AjaxControlToolkit.ExtenderControlBase.OnPreRender(EventArgs e) +36
AjaxControlToolkit.ValidatorCalloutExtender.OnPreRender(EventArgs e) +124
System.Web.UI.Control.PreRenderRecursiveInternal() +103
System.Web.UI.Control.PreRenderRecursiveInternal() +175
System.Web.UI.Control.PreRenderRecursiveInternal() +175
System.Web.UI.Control.PreRenderRecursiveInternal() +175
System.Web.UI.Control.PreRenderRecursiveInternal() +175
System.Web.UI.Control.PreRenderRecursiveInternal() +175
System.Web.UI.Control.PreRenderRecursiveInternal() +175
System.Web.UI.Control.PreRenderRecursiveInternal() +175
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2496
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1
我错在哪里.. 请帮帮我......