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