HOW TO FIX THIS ERROR Type 'System.Web.UI.WebControls.ValidationSummary' does not have a public property named 'label'.

USER 0 Reputation points
2023-12-07T02:51:53.8466667+00:00
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="SignUp.aspx.cs" Inherits="VisionSpaceTourism.SignUp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
    <h2>Add New Customer</h2>
   <div>
        <asp:ValidationSummary ID="ValidationId" runat="server" >
        <label for="txt_firstname">First Name: </label>
        <asp:TextBox ID="txt_firstname" runat="server"></asp:TextBox>
        <asp:RequiredFieldValidator ID="sp_txt_firstname" runat="server" ControlToValidate="txt_firstname" ErrorMessage="firstname is mandatory" ValidationGroup="AddingCustomerValidation"></asp:RequiredFieldValidator>
        <br />
        <br />
   </div>
    <div>
        <label for="txt_Lastname">Last Name:</label>
        <asp:TextBox ID="txt_Lastname" runat="server"></asp:TextBox>
        <asp:RequiredFieldValidator ID="sp_txt_lastname" runat="server" ControlToValidate="txt_Lastname" ErrorMessage="lastname is mandatory" ValidationGroup="AddingCustomerValidation"></asp:RequiredFieldValidator>
        <br />
        <br />
    </div>
   <div>
        <label for="txt_Usrname">Customer Login:</label>
        <asp:TextBox ID="txt_Username" runat="server"></asp:TextBox>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txt_Username" ErrorMessage="username is mandatory" ValidationGroup="AddingCustomerValidation"></asp:RequiredFieldValidator>
        <br />
        <br />
    </div>
    <div>
        <label for="txt_mail">Email:</label>
        <asp:TextBox ID="txt_mail" runat="server"></asp:TextBox>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txt_mail" ErrorMessage="email is mandatory" ValidationGroup="AddingCustomerValidation"></asp:RequiredFieldValidator>
        <br />
        <br />
    </div>
    <div>
        <label for="txt_Passwd">Password:</label>
        <asp:TextBox ID="txt_Passwd" runat="server" TextMode="Password"></asp:TextBox>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="txt_Passwd" ErrorMessage="password is mandatory" ValidationGroup="AddingCustomerValidation"></asp:RequiredFieldValidator>
        <br />
        <br />
    </div>
   <div>
        <label for="txt_ConfirmPasswd">Confirm Password:</label>
        <asp:TextBox ID="txt_ConfirmPasswd" runat="server" TextMode="Password"></asp:TextBox>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="txt_ConfirmPasswd" ErrorMessage="password is mandatory" ValidationGroup="AddingCustomerValidation"></asp:RequiredFieldValidator>
        <br />
        <br />
    </div>
    <div>
         <label for="txt_yob">YOB:</label>
         <asp:TextBox ID="txt_yob" runat="server"></asp:TextBox>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ControlToValidate="txt_yob" ErrorMessage="yob is mandatory" ValidationGroup="AddingCustomerValidation"></asp:RequiredFieldValidator>
         <br />
         <br />
    </div>
    <div>
            <asp:Button ID="CreateAcct" runat="server" Text="Create Account" OnClick="CreateAccount_Clk" />
            <br />
            <br />
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:SpaceTourConnectionString2 %>" SelectCommand="SELECT * FROM [CUSTOMER]" InsertCommand="INSERT INTO [CUSTOMER] ([CUS_LOGIN], [CUS_PWD], [CUS_FNAME], [CUS_LNAME], [CUS_EMAIL], [CUS_YOB]) VALUES (@CUS_LOGIN, @CUS_PWD, @CUS_FNAME, @CUS_LNAME, @CUS_EMAIL, @CUS_YOB)" DeleteCommand="DELETE FROM [CUSTOMER] WHERE [CUS_NUM] = @CUS_NUM" UpdateCommand="UPDATE [CUSTOMER] SET [CUS_LOGIN] = @CUS_LOGIN, [CUS_PWD] = @CUS_PWD, [CUS_FNAME] = @CUS_FNAME, [CUS_LNAME] = @CUS_LNAME, [CUS_EMAIL] = @CUS_EMAIL, [CUS_YOB] = @CUS_YOB WHERE [CUS_NUM] = @CUS_NUM">
                <DeleteParameters>
                    <asp:Parameter Name="CUS_NUM" Type="Int32" />
                </DeleteParameters>
                <InsertParameters>
                    <asp:Parameter Name="CUS_LOGIN" Type="String" />
                    <asp:Parameter Name="CUS_PWD" Type="String" />
                    <asp:Parameter Name="CUS_FNAME" Type="String" />
                    <asp:Parameter Name="CUS_LNAME" Type="String" />
                    <asp:Parameter Name="CUS_EMAIL" Type="String" />
                    <asp:Parameter Name="CUS_YOB" Type="Int32" />
                </InsertParameters>
                <UpdateParameters>
                    <asp:Parameter Name="CUS_LOGIN" Type="String" />
                    <asp:Parameter Name="CUS_PWD" Type="String" />
                    <asp:Parameter Name="CUS_FNAME" Type="String" />
                    <asp:Parameter Name="CUS_LNAME" Type="String" />
                    <asp:Parameter Name="CUS_EMAIL" Type="String" />
                    <asp:Parameter Name="CUS_YOB" Type="Int32" />
                    <asp:Parameter Name="CUS_NUM" Type="Int32" />
                </UpdateParameters>
            </asp:SqlDataSource>
            <br />

        <asp:Label ID="lblError" runat="server" ForeColor="Red"></asp:Label>

      </div>

</asp:Content>
  
Bing Visual Search
Bing Visual Search
A Bing service that gives you rich insights to help build compelling image applications on the device of your choice.
25 questions
{count} votes

1 answer

Sort by: Most helpful
  1. navba-MSFT 24,985 Reputation points Microsoft Employee
    2023-12-07T03:17:47.0366667+00:00

    @USER Welcome to Microsoft Q&A Forum, Thank you for posting your query here!
    .
    I understand that you are encountering the error 'System.Web.UI.WebControls.ValidationSummary' does not have a public property named 'label'.

    .
    The error you’re encountering is because the asp:ValidationSummary control does not have a public property named ‘label’. In your code, you’re trying to nest a <label> element inside the asp:ValidationSummary control, which is causing the error.

    Here’s how you can fix it:

    <asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
        <h2>Add New Customer</h2>
       <div>
            <label for="txt_firstname">First Name: </label>
            <asp:TextBox ID="txt_firstname" runat="server"></asp:TextBox>
            <asp:RequiredFieldValidator ID="sp_txt_firstname" runat="server" ControlToValidate="txt_firstname" ErrorMessage="firstname is mandatory" ValidationGroup="AddingCustomerValidation"></asp:RequiredFieldValidator>
            <br />
            <br />
       </div>
    
       <!-- Rest of your code -->
    
       <asp:ValidationSummary ID="ValidationId" runat="server" />
    </asp:Content>
    
    

    In the corrected code, I’ve moved the asp:ValidationSummary control outside the <div> block.
    Also you need to close the tag correctly "/>" as shown below:

    <asp:ValidationSummary ID="ValidationId" runat="server" />

    Now, it’s not nested with any other elements, which should resolve the error. Please replace the <!-- Rest of your code --> comment with the rest of your code. Let me know if you need further assistance!
    .

    Hope this helps. If you have any follow-up questions, please let me know. I would be happy to help.
    .

    ** Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.