asp.net mvc - Partial Views & ModelState.AddModelError -


the source of loginregister view :

@html.partial("authentication/_login") @html.partial("authentication/_register") 

and each child view has got form syntax

@using (html.beginform(**seperated-methods**, "login"))  {     @html.validationsummary(false) }  

i send error(s) in postback whit code

modelstate.addmodelerror("", "**any-error-message**"); return view("authentication/loginregister", customized-data); 

the point , error message shows in both partial views.

you need tell modelstate property error refer to:

modelstate.addmodelerror("propertyname", "**any-error-message**"); 

now in

@html.validationmessagefor(m => m.propertyname) 

if don't specify property name, error considered global , shown in every validationsummary.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -