Click here to Skip to main content
15,902,032 members
Home / Discussions / C#
   

C#

 
AnswerRe: C#, Winforms, Coding Pin
Richard MacCutchan4-Nov-23 0:11
mveRichard MacCutchan4-Nov-23 0:11 
AnswerRe: C#, Winforms, Coding Pin
Andre Oosthuizen10-Nov-23 6:28
mveAndre Oosthuizen10-Nov-23 6:28 
QuestionHow to customize the default error message "The value '' is invalid" for dynamically generated form Pin
Fokwa Divine1-Nov-23 4:30
Fokwa Divine1-Nov-23 4:30 
I am new to asp.net core. I have a form which is generated dynamically. I want the validation error message to be "The value must be numeric" instead I get "The value 'a' is invalid" when I submit the form.

Here is my View Model:
C#
[RegularExpression("^[0-9]*$", ErrorMessage = "The value must be numeric")]
public List<int> Units_Service { get; set; }


Here is my form code:
HTML
for (int i = 0; i < Model.Workload_Category_Name.Count; i++)
{
   <div class="row">
       <div class="col-md-3">
           <b></u>@Html.DisplayFor(model => model.Workload_Category_Name[i])</u> </b>
       </div>
       <div class="col-md-4">
          @Html.TextBoxFor(model => model.Units_Service[i], new { style = "width: 15%", MaskedTextBox = "9999" })
          @Html.ValidationMessageFor(model => model.Units_Service[i])
       </div>
   </div>
 }


Despite the fact, I have put the custom error message in my View Model as shown above, I keep getting the default message "The value '' is invalid". Please what is the solution to this kind of scenario ?
AnswerRe: How to customize the default error message "The value '' is invalid" for dynamically generated form Pin
Richard Deeming1-Nov-23 5:47
mveRichard Deeming1-Nov-23 5:47 
GeneralRe: How to customize the default error message "The value '' is invalid" for dynamically generated form Pin
Fokwa Divine1-Nov-23 8:51
Fokwa Divine1-Nov-23 8:51 
AnswerRe: How to customize the default error message "The value '' is invalid" for dynamically generated form Pin
jschell2-Nov-23 4:30
jschell2-Nov-23 4:30 
GeneralRe: How to customize the default error message "The value '' is invalid" for dynamically generated form Pin
Fokwa Divine3-Nov-23 6:34
Fokwa Divine3-Nov-23 6:34 
Questionc Pin
Gorla Bhagyasree31-Oct-23 23:19
Gorla Bhagyasree31-Oct-23 23:19 
AnswerRe: c Pin
Richard Deeming31-Oct-23 23:56
mveRichard Deeming31-Oct-23 23:56 
AnswerRe: c Pin
Pete O'Hanlon1-Nov-23 21:26
mvePete O'Hanlon1-Nov-23 21:26 
QuestionC# How to grab html from selection of web browser control Pin
Tridip Bhattacharjee from Unknown26-Oct-23 11:15
Tridip Bhattacharjee from Unknown26-Oct-23 11:15 
SuggestionRe: C# How to grab html from selection of web browser control Pin
Richard Deeming26-Oct-23 21:47
mveRichard Deeming26-Oct-23 21:47 
GeneralRe: C# How to grab html from selection of web browser control Pin
Tridip Bhattacharjee from Unknown27-Oct-23 3:38
Tridip Bhattacharjee from Unknown27-Oct-23 3:38 
GeneralRe: C# How to grab html from selection of web browser control Pin
Richard Deeming27-Oct-23 3:51
mveRichard Deeming27-Oct-23 3:51 
QuestionADP Enterprise API help Pin
Mike Olmon 202125-Oct-23 12:10
Mike Olmon 202125-Oct-23 12:10 
AnswerRe: ADP Enterprise API help Pin
Richard Deeming25-Oct-23 22:32
mveRichard Deeming25-Oct-23 22:32 
GeneralRe: ADP Enterprise API help Pin
jschell26-Oct-23 4:58
jschell26-Oct-23 4:58 
QuestionIs there a way to Convert binding dataMember? Pin
Geanny Martin24-Oct-23 2:50
Geanny Martin24-Oct-23 2:50 
AnswerRe: Is there a way to Convert binding dataMember? Pin
Alan N24-Oct-23 4:21
Alan N24-Oct-23 4:21 
NewsEvergrowth.AspForMarkDigExtension is out there now... Pin
James McCullough19-Oct-23 15:25
professionalJames McCullough19-Oct-23 15:25 
GeneralRe: Evergrowth.AspForMarkDigExtension is out there now... Pin
OriginalGriff19-Oct-23 18:22
mveOriginalGriff19-Oct-23 18:22 
GeneralRe: Evergrowth.AspForMarkDigExtension is out there now... Pin
James McCullough19-Oct-23 18:42
professionalJames McCullough19-Oct-23 18:42 
GeneralRe: Evergrowth.AspForMarkDigExtension is out there now... Pin
OriginalGriff19-Oct-23 20:39
mveOriginalGriff19-Oct-23 20:39 
GeneralRe: Evergrowth.AspForMarkDigExtension is out there now... Pin
jschell20-Oct-23 11:28
jschell20-Oct-23 11:28 
QuestionC# How to iterate in all TR & TD of multiple html table and extract value Pin
Tridip Bhattacharjee from Unknown18-Oct-23 23:11
Tridip Bhattacharjee from Unknown18-Oct-23 23:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.