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