请帮我朋友, 我创建modalpopupextender,我在mpe内的文本框上使用asp requirefieldvalidator ..当我点击按钮提交时,rfv已经出现。但问题来自我点击取消按钮..面板将关闭。但是当我再次点击链接mpe时,仍会显示错误消息。这是我的代码:
<cc1:ModalPopupExtender ID="mpeSignUp"
runat="server" PopupControlID="pnlPopupSignUp"
TargetControlID="lnkButtonSignUp"
CancelControlID="btnCancelSignUp"
OnCancelScript="DoCancel()"
DropShadow="true" BackgroundCssClass="modalBackground">
</cc1:ModalPopupExtender>
<asp:Panel ID="pnlPopupSignUp" runat="server" CssClass="modalPopupSignUp" Style="display: none">
<asp:TextBox ID="txtUsername" runat="server" CssClass="twitterStyleTextbox" plceholder="Username" />
<asp:RequiredFieldValidator ID="rfvtxtUsername" ErrorMessage="Required" ForeColor="Red" ControlToValidate="txtUsername" runat="server" EnableClientScript="false" /> <br />
<script type="text/javascript">
function DoCancel() {
$get('<%=txtEmail.ClientID%>').value = "";
$get('<%=txtPassword.ClientID%>').value = "";
$get('<%=txtUsername.ClientID%>').value = "";
$get('<%=txtPasswordSignUp.ClientID%>').value = "";
$get('<%=txtConfirmPasswordSignUp.ClientID%>').value = "";
$get('<%=txtEmailSignUp.ClientID%>').value = "";
}
</script>
代码背后的代码:
Protected Sub btnSignUp_Click(sender As Object, e As EventArgs) Handles btnSignUp.Click
mpeSignUp.Show()
End Sub
答案 0 :(得分:0)
如果你的aspx中没有更新面板,你应该尝试使用一个并尝试使用asynpostbacktrigger触发:
未测试的示例:
<asp:UpdatePanel ID="UpdatePanel1" CssClass="popup" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false">
<ContentTemplate>
<cc1:ModalPopupExtender ID="mpeSignUp"
runat="server" PopupControlID="pnlPopupSignUp"
TargetControlID="lnkButtonSignUp"
CancelControlID="btnCancelSignUp"
OnCancelScript="DoCancel()"
DropShadow="true" BackgroundCssClass="modalBackground">
</cc1:ModalPopupExtender>
<asp:Panel ID="pnlPopupSignUp" runat="server" CssClass="modalPopupSignUp" Style="display: none">
<asp:TextBox ID="txtUsername" runat="server" CssClass="twitterStyleTextbox" plceholder="Username" />
<asp:RequiredFieldValidator ID="rfvtxtUsername" ErrorMessage="Required" ForeColor="Red" ControlToValidate="txtUsername" runat="server" EnableClientScript="false" /> <br />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnCancelSignUp" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
希望这有帮助!
答案 1 :(得分:0)
无论如何我已经找到了答案@ jomsk1e。
我在js上添加了这段代码:
document.getElementById('<%=rfvtxtUsername.ClientID%>').innerHTML = "";
document.getElementById('<%=rfvtxtPasswordSignUp.ClientID%>').innerHTML = "";
document.getElementById('<%=rfvtxtEmailSignUp.ClientID%>').innerHTML = "";