You can use a validation summary control in ASP.NET when you want to show a detail description of the error messages. The error message is assign to the "ErrorMessage" property of each validation control and "Text" property is assign to "*".
Following would be your HTML code.
<asp:ValidationSummary ID="ValidationSummary1" runat="server"
ForeColor="#CC0000" />
<table>
<tr>
<td>
Name:</td>
<td>
<asp:TextBox ID="txtName" runat="server" Width="153px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="txtName" ErrorMessage="Name Required" ForeColor="#CC0000">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
Address:</td>
<td>
<asp:TextBox ID="txtAddress" runat="server" Width="155px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="txtAddress" ErrorMessage="Address Required"
ForeColor="#CC0000">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
Profession:</td>
<td>
<asp:TextBox ID="txtProf" runat="server" Width="153px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ControlToValidate="txtProf" ErrorMessage="Profession Required"
ForeColor="#CC0000">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
Desscription:</td>
<td>
<asp:TextBox ID="txtdescription" runat="server" Width="152px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
ControlToValidate="txtdescription" ErrorMessage="Description Required"
ForeColor="#CC0000">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:Button ID="btnSubmit" runat="server" Text="Submit" />
</td>
</tr>
</table>
No comments:
Write comments