I have googled this extensively and couldn't find an answer, so I am posting this here hoping for help.
We have an asp.net 4.5 project with validation specified in the database objects classes. For example:
[Required(ErrorMessage = "Name is a required field.")]
public string Name { get; set; }
Is there any way at all that we can have this error message show up next to the field on the form page? The validation summary shows up just fine but we would really like to have them show up next to their respective fields without using the traditional, code-heavy asp.net validators (RequiredFieldValidator and others).
Thanks for the help.
EDIT: we are using webforms, not MVC
You can use the ModelErrorMessage control. For example, let's pretend you have a model with a FirstName property. You would add something like this:
<asp:ModelErrorMessage ID="FirstNameErrorMessage" ModelStateKey="FirstName" runat="server" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With