我刚刚创建了一个包含MasterPage的网站。我有两个条件可以说明我的问题:
条件1:
我在website.master上添加了 ModalPopupExtender 。它有三个字段,每个字段都有 RequiredFieldValidator 和 ValidatorCalloutExtender 。
条件2:
我有几个不同的页面,您可以点击注册链接。单击注册链接时,将显示注册表单。此表单还为每个字段提供 RequiredFieldValidators 和 ValidatorCalloutExtenders 。
问题:
如果我打开注册表并希望提供反馈,请点击反馈按钮。反馈模式弹出窗口显示。如果我单击提交按钮而不填写反馈表单,则应该在 ModalPopupExtender 面板上以 ValidatorCalloutExtender 格式给出错误。但是,它并没有显示任何错误,但 ValidatorCalloutExtender 确实会在注册表单上显示相应的验证。
<cc1:ModalPopupExtender CancelControlID="lnk_cancel" ID="popup_change_password" BackgroundCssClass="modalBackground"
runat="server" TargetControlID="ImageButton1" PopupControlID="panel_change_password">
</cc1:ModalPopupExtender>
<asp:Panel ID="panel_change_password" runat="server" Style="display: none; height: 400px;
width: 400px; padding-left:30px; background-repeat:no-repeat;" BackImageUrl="~/Images/background.gif">
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td colspan="3" valign="top">
<table cellpadding="0" cellspacing="0" width="400px">
<tr>
<td align="right">
<asp:ImageButton ID="lnk_cancel" runat="server" ImageUrl="Images/close.gif" Height="30px"
Width="30px" />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="3">
<asp:Label ID="lbl_new_password" runat="server" Text="Your feedback is important to us."
CssClass="login_font1"></asp:Label>
</td>
</tr>
<tr>
<td colspan="3">
</td>
</tr>
<tr>
<td>
<asp:Label ID="lbl_name" runat="server" Text="Name" CssClass="Label_Styles"></asp:Label>
</td>
<td>
:
</td>
<td>
<asp:TextBox ID="txt_name" runat="server" CssClass="Textbox_Styles"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="3">
</td>
</tr>
<tr>
<td>
<asp:Label ID="lbl_email" runat="server" Text="Email Address" CssClass="Label_Styles"></asp:Label>
</td>
<td>
:
</td>
<td>
<asp:TextBox ID="txt_email" runat="server" CssClass="Textbox_Styles"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="3">
</td>
</tr>
<tr>
<td>
<asp:Label ID="lbl_comment" runat="server" Text="Comments" CssClass="Label_Styles"></asp:Label>
</td>
<td>
:
</td>
<td>
<asp:TextBox ID="txt_comment" runat="server" CssClass="Textbox_Styles" Height="120px"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="3">
</td>
</tr>
</table>
</asp:Panel>
答案 0 :(得分:0)
将上述代码放入UpdatePanel
UpdateMode="Conditional"
和ChildrenAsTriggers="False".
所以它看起来像:
<asp:UpdatePanel ID="sbsModalExtenderUpdatePanel" runat="server" UpdateMode="Conditional"
Visible="False" ChildrenAsTriggers="False">
<ContentTemplate>
<asp:Panel ID="StepByStepBookingPanel" runat="server" Enabled="false" EnableViewState="false"
Style="display: block" CssClass="mediumModalPopup" ScrollBars="Auto" Width="800px"
Height="300px" ViewStateMode="Enabled">
<div id="clientCoordDiv" runat="server">
<table id="StepByStepTable" runat="server">
等...
</table>
</div>
</asp:Panel>
<ajax:ModalPopupExtender ID="mpeStepByStepBooking" runat="server" BackgroundCssClass="modalBackground"
PopupControlID="StepByStepBookingPanel" CancelControlID="BtnCancel" OnCancelScript="ClearStepByStepPopup"
TargetControlID="hdnStepByStepButton" DropShadow="true" BehaviorID="modalwithinput" />
<asp:CompareValidator ID="ClientCoordinatorCompareValidator" runat="server" ErrorMessage="Please select a Client Coordinator"
ControlToValidate="ddlClientCoordinator" Display="None" Operator="NotEqual" SetFocusOnError="True"
Type="Integer" ValueToCompare="0" ValidationGroup="SelectionRequired">
</asp:CompareValidator>
<asp:CompareValidator ID="CVOCoordinatorCompareValidator" runat="server" ErrorMessage="Please select a CVO Coordinator"
ControlToValidate="ddlCVOCoordinator" Display="None" Operator="NotEqual" ValueToCompare="0"
Type="Integer" SetFocusOnError="True" ValidationGroup="SelectionRequired">
</asp:CompareValidator>
<ajax:ValidatorCalloutExtender ID="CompareClientCoordinatorExt" runat="server" Enabled="True"
TargetControlID="ClientCoordinatorCompareValidator" BehaviorID="ClientValidatorExt">
</ajax:ValidatorCalloutExtender>
<ajax:ValidatorCalloutExtender ID="CVOCoordinatorCompareValidatorExt" BehaviorID="CVOValidatorExt"
runat="server" Enabled="True" TargetControlID="CVOCoordinatorCompareValidator">
</ajax:ValidatorCalloutExtender>
</ContentTemplate>
</asp:UpdatePanel>
这将在您验证时保持对话框。不幸的是,由于我的验证器消息没有显示,我没有完整的解决方案。到目前为止,从我在网上获得的内容来看,它是Ajax库的一个问题。丑陋! 哦,希望这有助于某人...