Hello, I am trying to validate a form using ModelState generally the same way as in tutorials on asp.net/mvc. However I dont have my own database or their objects and want to validate against Formcollection. I am not sure, how ModelState works, so maybe I am shooting in the dark, but here is the code, that crashes:
<%=Html.TextBox(Html.Encode("atr_" + name.Key), ViewData["atr_" + name.Key])%> <%=Html.ValidationMessage("atr_" + name.Key, "*")%>
and NullReferenceException I get on the TextBox:
System.NullReferenceException: Object reference not set to an instance of an object. at System.Web.Mvc.HtmlHelper.GetModelStateValue(String key, Type destinationType) at System.Web.Mvc.Html.InputExtensions.InputHelper(HtmlHelper htmlHelper, InputType inputType, String name, Object value, Boolean useViewData, Boolean isChecked, Boolean setId, Boolean isExplicitValue, IDictionary2 htmlAttributes) at System.Web.Mvc.Html.InputExtensions.TextBox(HtmlHelper htmlHelper, String name, Object value, IDictionary
2 htmlAttributes) at System.Web.Mvc.Html.InputExtensions.TextBox(HtmlHelper htmlHelper, String name, Object value) at ASP.views_authorized_account_aspx.__RenderContent1(HtmlTextWriter __w, Control parameterContainer) in c:\Users\Trimack\Documents\Visual Studio 2008\Projects\GuestManager\AccountManager\Views\Authorized\Account.aspx:line 61*
Any ideas? Or am I completely wrong?
Trimack