1 write to ModelState
Microsoft.AspNetCore.Mvc.ViewFeatures (1)
ViewDataDictionary.cs (1)
250
ModelState
= modelState;
118 references to ModelState
Microsoft.AspNetCore.Mvc.RazorPages (2)
PageBase.cs (1)
1185
var viewData = new ViewDataDictionary(MetadataProvider, ViewContext.ViewData.
ModelState
)
PageModel.cs (1)
1543
var viewData = new ViewDataDictionary(MetadataProvider, ViewData.
ModelState
)
Microsoft.AspNetCore.Mvc.ViewFeatures (14)
DefaultHtmlGenerator.cs (9)
582
if (viewContext.ViewData.
ModelState
.TryGetValue(fullName, out var entry))
632
viewContext.ViewData.
ModelState
.TryGetValue(fullName, out var entry);
735
if (!viewContext.ViewData.
ModelState
.ContainsKey(fullName) && formContext == null)
740
var tryGetModelStateResult = viewContext.ViewData.
ModelState
.TryGetValue(fullName, out var entry);
811
if (!viewContext.ClientValidationEnabled && viewData.
ModelState
.IsValid)
818
(!viewData.
ModelState
.TryGetValue(viewData.TemplateInfo.HtmlFieldPrefix, out var entryForModel) ||
874
if (viewData.
ModelState
.IsValid)
1066
if (viewContext.ViewData.
ModelState
.TryGetValue(key, out var entry) && entry.RawValue != null)
1262
if (viewContext.ViewData.
ModelState
.TryGetValue(fullName, out var entry) && entry.Errors.Count > 0)
ValidationHelpers.cs (3)
50
viewData.
ModelState
.TryGetValue(viewData.TemplateInfo.HtmlFieldPrefix, out var ms);
57
else if (viewData.
ModelState
.Count > 0)
60
var modelStateDictionary = viewData.
ModelState
;
ViewComponent.cs (1)
75
public ModelStateDictionary ModelState => ViewData?.
ModelState
!;
ViewDataDictionary.cs (1)
179
source.
ModelState
,
Microsoft.AspNetCore.Mvc.ViewFeatures.Test (102)
ControllerUnitTestabilityTests.cs (2)
629
Assert.Equal(controller1.ModelState, controller1.ViewData.
ModelState
);
633
Assert.Equal(controller1.ControllerContext.ModelState, controller2.ViewData.
ModelState
);
DefaultEditorTemplatesTest.cs (1)
535
viewData.
ModelState
.SetModelValue("FieldPrefix", "Raw model string", "Attempted model string");
Rendering\HtmlHelperCheckboxTest.cs (3)
266
helper.ViewData.
ModelState
.SetModelValue("Property1", new string[] { "false" }, "false");
571
viewData.
ModelState
.SetModelValue("Property1", new string[] { "false" }, "false");
666
viewData.
ModelState
.SetModelValue("Property1", new string[] { attemptedValue }, attemptedValue);
Rendering\HtmlHelperDisplayTextTest.cs (2)
262
viewData.
ModelState
.SetModelValue(
287
viewData.
ModelState
.SetModelValue(
Rendering\HtmlHelperDropDownListExtensionsTest.cs (3)
33
helper.ViewData.
ModelState
.SetModelValue("Property1", 3, "3");
57
helper.ViewData.
ModelState
.SetModelValue("Property1", 1, "1");
108
helper.ViewData.
ModelState
.SetModelValue("Property1", 4, "4");
Rendering\HtmlHelperHiddenTest.cs (19)
215
helper.ViewData.
ModelState
.Clear();
231
helper.ViewData.
ModelState
.Clear();
376
helper.ViewData.
ModelState
.Clear();
377
helper.ViewData.
ModelState
.SetModelValue(
381
helper.ViewData.
ModelState
.SetModelValue(
385
helper.ViewData.
ModelState
.SetModelValue(
407
helper.ViewData.
ModelState
.Clear();
633
helper.ViewData.
ModelState
.Clear();
650
helper.ViewData.
ModelState
.Clear();
703
helper.ViewData.
ModelState
.Clear();
704
helper.ViewData.
ModelState
.SetModelValue(
708
helper.ViewData.
ModelState
.SetModelValue(
712
helper.ViewData.
ModelState
.SetModelValue(
855
viewData.
ModelState
.SetModelValue("pre.Property3[key]", "Prop3Val", "Prop3Val");
856
viewData.
ModelState
.SetModelValue("pre.Property4.Property5", "Prop5Val", "Prop5Val");
857
viewData.
ModelState
.SetModelValue("pre.Property4.Property6[0]", "Prop6Val", "Prop6Val");
964
viewData.
ModelState
.SetModelValue("Property1", "ModelStateValue", "ModelStateValue");
972
viewData.
ModelState
.AddModelError("Property1", "error 1");
973
viewData.
ModelState
.AddModelError("Property1", "error 2");
Rendering\HtmlHelperListBoxExtensionsTest.cs (1)
33
helper.ViewData.
ModelState
.SetModelValue("Property1", 2, "2");
Rendering\HtmlHelperPasswordTest.cs (9)
356
viewData.
ModelState
.SetModelValue("pre.Property3[key]", "Property3Val", "Property3Val");
357
viewData.
ModelState
.SetModelValue("pre.Property4.Property5", "Property5Val", "Property5Val");
358
viewData.
ModelState
.SetModelValue("pre.Property4.Property6[0]", "Property6Val", "Property6Val");
458
viewData.
ModelState
.SetModelValue("Property1", "ModelStateValue", "ModelStateValue");
466
viewData.
ModelState
.AddModelError("Property1", "error 1");
467
viewData.
ModelState
.AddModelError("Property1", "error 2");
507
helper.ViewData.
ModelState
.SetModelValue("pre.Property3[key]", "MProp3Val", "MProp3Val");
508
helper.ViewData.
ModelState
.SetModelValue("pre.Property4.Property5", "MProp5Val", "MProp5Val");
509
helper.ViewData.
ModelState
.SetModelValue("pre.Property4.Property6[0]", "MProp6Val", "MProp6Val");
Rendering\HtmlHelperTextAreaTest.cs (3)
124
helper.ViewData.
ModelState
.SetModelValue("pre.Property3[key]", "MProp3Val", "MProp3Val");
125
helper.ViewData.
ModelState
.SetModelValue("pre.Property4.Property5", "MProp5Val", "MProp5Val");
126
helper.ViewData.
ModelState
.SetModelValue("pre.Property4.Property6[0]", "MProp6Val", "MProp6Val");
Rendering\HtmlHelperTextBoxTest.cs (3)
142
helper.ViewData.
ModelState
.SetModelValue("pre.Property3[key]", "MProp3Val", "MProp3Val");
143
helper.ViewData.
ModelState
.SetModelValue("pre.Property4.Property5", "MProp5Val", "MProp5Val");
144
helper.ViewData.
ModelState
.SetModelValue("pre.Property4.Property6[0]", "MProp6Val", "MProp6Val");
Rendering\HtmlHelperValidationSummaryTest.cs (43)
209
html.ViewData.
ModelState
.AddModelError(string.Empty, "This is my validation message");
235
html.ViewData.
ModelState
.AddModelError("this.is.my.prefix", "This is my validation message");
260
html.ViewData.
ModelState
.AddModelError("Property1", "This is my validation message");
284
AddMultipleErrors(html.ViewData.
ModelState
);
310
AddMultipleErrors(html.ViewData.
ModelState
);
311
html.ViewData.
ModelState
.RemoveAll<ValidationModel>(m => m.Property2);
312
html.ViewData.
ModelState
.Remove<ValidationModel>(m => m.Property3);
313
html.ViewData.
ModelState
.Remove<ValidationModel>(m => m.Property3.OrderedProperty2);
314
html.ViewData.
ModelState
.AddModelError("Property2", "New error for Property2.");
347
AddMultipleErrors(html.ViewData.
ModelState
);
348
html.ViewData.
ModelState
.AddModelError("non-existent-property1", "non-existent-error1");
349
html.ViewData.
ModelState
.AddModelError("non.existent.property2", "non-existent-error2");
350
html.ViewData.
ModelState
.AddModelError("non.existent[0].property3", "non-existent-error3");
376
html.ViewData.
ModelState
.AddModelError("Property1", "Property1 error");
377
html.ViewData.
ModelState
.AddModelError("Property2[0].OrderedProperty1", "Property2[0].OrderedProperty1 error");
378
html.ViewData.
ModelState
.AddModelError("Property2[10].Property2", "Property2[10].Property2 error");
379
html.ViewData.
ModelState
.AddModelError("Property2[2].Property3", "Property2[2].Property3 error");
380
html.ViewData.
ModelState
.AddModelError("Property2[0].Property1", "Property2[0].Property1 error");
406
html.ViewData.
ModelState
.AddModelError("[0].OrderedProperty2", "[0].OrderedProperty2 error");
407
html.ViewData.
ModelState
.AddModelError("[0].Property1", "[0].Property1 error");
408
html.ViewData.
ModelState
.AddModelError("[0].OrderedProperty1", "[0].OrderedProperty1 error");
409
html.ViewData.
ModelState
.AddModelError("[2].Property3", "[2].Property3 error");
410
html.ViewData.
ModelState
.AddModelError("[2].OrderedProperty3", "[2].OrderedProperty3 error");
438
html.ViewData.
ModelState
.AddModelError("[0].OrderedProperty2", "[0].OrderedProperty2 error");
439
html.ViewData.
ModelState
.AddModelError("[0].Property1", "[0].Property1 error");
440
html.ViewData.
ModelState
.AddModelError("[0].OrderedProperty1", "[0].OrderedProperty1 error");
441
html.ViewData.
ModelState
.AddModelError("[2].Property3", "[2].Property3 error");
442
html.ViewData.
ModelState
.AddModelError("[2].OrderedProperty3", "[2].OrderedProperty3 error");
443
html.ViewData.
ModelState
.AddModelError("OrderedProperty1", "OrderedProperty1 error");
444
html.ViewData.
ModelState
.AddModelError("OrderedProperty2", "OrderedProperty2 error");
477
AddOrderedErrors(html.ViewData.
ModelState
);
495
helper.ViewData.
ModelState
.AddModelError("Property1", "Error for Property1");
513
helper.ViewData.
ModelState
.AddModelError("Property1", "Error for Property1");
527
helper.ViewData.
ModelState
.AddModelError("Property1", "Error for Property1");
546
helper.ViewData.
ModelState
.AddModelError("Property1", "Error for Property1");
565
helper.ViewData.
ModelState
.AddModelError(string.Empty, "Error for root");
566
helper.ViewData.
ModelState
.AddModelError("Property1", "Error for Property1");
585
helper.ViewData.
ModelState
.AddModelError("Property1", "Error for Property1");
604
helper.ViewData.
ModelState
.AddModelError("Property1", "Error for Property1");
623
helper.ViewData.
ModelState
.AddModelError(string.Empty, "Error for root");
624
helper.ViewData.
ModelState
.AddModelError("Property1", "Error for Property1");
643
helper.ViewData.
ModelState
.AddModelError(string.Empty, "Error for root");
644
helper.ViewData.
ModelState
.AddModelError("Property1", "Error for Property1");
Rendering\HtmlHelperValueTest.cs (3)
163
viewData.
ModelState
.SetModelValue(
168
viewData.
ModelState
.SetModelValue(
220
viewData.
ModelState
.SetModelValue(
ViewDataDictionaryOfTModelTest.cs (6)
22
Assert.Same(modelState, viewData.
ModelState
);
47
Assert.NotNull(viewData1.
ModelState
);
59
Assert.NotNull(viewData2.
ModelState
);
86
Assert.NotNull(viewData1.
ModelState
);
98
Assert.NotNull(viewData2.
ModelState
);
166
Assert.NotNull(viewData.
ModelState
);
ViewDataDictionaryTest.cs (3)
22
Assert.NotNull(viewData.
ModelState
);
40
Assert.Same(modelState, viewData.
ModelState
);
201
Assert.NotNull(viewData.
ModelState
);
ViewDataOfTTest.cs (1)
65
Assert.NotNull(viewData.
ModelState
);