In my application (written in c#) I have a textbox and a submit button.
If the user clicks “submit” without entering any value, I want him to stay at the same page and display a message saying “Please insert value”
I thought to put a label, and then just edit its value and/or visibility.
The structure of my application is as following:
Controller A
inside View, under A, I have B.aspx
and inside B.aspx I call a partial C.ascx
The submit form with my label are inside C.ascx
How can I change the lable value and/or visibility?
You should use the Data Validation Attributes for this.
Something like this:
This will create a custom javascript/jquery file that will perform the appropriate validation for you.
You can even change the default error message for Required.