Search code examples
asp.netajaxmodalpopupextender

RequiredFieldValidator error message persists even after closing ModalPopupExtender


please help me friend, i create modalpopupextender, and i use asp requirefieldvalidator on textbox inside the mpe.. the rfv is already appear when i click button submit. but the problem comes when i click the cancel button.. the panel will close. but when i click link mpe again the error message still appear. and this is my code :

<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> 

code behind :

Protected Sub btnSignUp_Click(sender As Object, e As EventArgs) Handles btnSignUp.Click

    mpeSignUp.Show()

End Sub

Solution

  • i already found the answer thx anyway @jomsk1e.

    i added this code on js :

    document.getElementById('<%=rfvtxtUsername.ClientID%>').innerHTML = "";
    document.getElementById('<%=rfvtxtPasswordSignUp.ClientID%>').innerHTML = "";
    document.getElementById('<%=rfvtxtEmailSignUp.ClientID%>').innerHTML = "";