开发者

Problem with client side validation

开发者 https://www.devze.com 2023-01-28 23:29 出处:网络
Hi I am developing a web page which will give the details of customer. I have several validations for input fields and used DetailsView for displaying details of customer. If the user details does not

Hi I am developing a web page which will give the details of customer. I have several validations for input fields and used DetailsView for displaying details of customer. If the user details does not exist in database Detailsview displays a message "No records found". Now if I enters an invalid user name validations are displayed but page still have the "No records found" message in EmptyDataTemplate of DetailsView. How can I remove "No records found" message or disable details view ? So that page should only show error messages and textbox fields.

   <asp:TextBox ID="TextBox_FirstName" runat="server"></asp:TextBox>
   <asp:RegularExpressionValidator ID="RegularExpressionValidator_FirstName" runat="server"
        ControlToValidate="TextBox_FirstName" ErrorMessage="Enter a valid 开发者_开发问答SSN" ForeColor="Red"
        SetFocusOnError="True">*</asp:RegularExpressionValidator>
    <br />
   <asp:TextBox ID="TextBox_LastName" runat="server"></asp:TextBox>
   <asp:RegularExpressionValidator ID="RegularExpressionValidator_LastName" runat="server"
        ControlToValidate="TextBox_LastName" ErrorMessage="Enter a valid date" ForeColor="Red">*</asp:RegularExpressionValidator>
   <asp:Button ID="txtSubmit" Text="Validate" runat="server" />
   <asp:CustomValidator ID="AtLeastOneTextBoxValidator" runat="server" ClientValidationFunction="Validate_Textbox"
        ValidateEmptyText="true"> </asp:CustomValidator>
    <asp:ValidationSummary ID="ValidationSummary" runat="server" />

    <asp:DetailsView ID="Client_DetailsView" runat="server">
        <EmptyDataTemplate>
             <strong>No Record Found.</strong>
        </EmptyDataTemplate>
    </asp:DetailsView> 


Change your code behind so that Client_DetailsView only gets data bound when they submit the form.

Also, set it's visibility to hidden in the .aspx then only set it to visible when the form is submitted.

0

精彩评论

暂无评论...
验证码 换一张
取 消