asp.net mvc 4 - The value "(string)" is invalid -


i have view contains 2 text boxes users can enter in data. 1 text box allows values of 1-10, other string. not sure code change made, second text box accepting string no longer "works". example, when enter in string , try submit form, validation message states "the value "(string)" invalid. below code snippets in solution.

entity:

public class moviereview {     public int id { get; set; }      [range(1, 10)]     [required]     public int rating { get; set; }     public string review { get; set; }     public int movieid { get; set; } } 

controller:

public class reviewscontroller : controller {     private movieloversdb _db = new movieloversdb();      public actionresult index([bind(prefix = "id")]int movieid)     {         var movie = _db.movies.find(movieid);         if (movie != null)         {             return view(movie);         }         return httpnotfound();     }      [httpget]     public actionresult create(int movieid)     {         return view();     }      [httppost]     public actionresult create(moviereview review)     {         if (modelstate.isvalid)         {             _db.moviereviews.add(review);             _db.savechanges();             return redirecttoaction("index", new { id = review.movieid });         }         return view(review);     } 

partial view:

@model movielovers.models.moviereview  @{     viewbag.title = "review movie"; }  <h2>review movie</h2>  @using (html.beginform()) {     @html.antiforgerytoken()     @html.validationsummary(true)  <fieldset>     <legend>new review</legend>      <div class="editor-label">         @html.labelfor(model => model.rating)     </div>     <div class="editor-field">         @html.editorfor(model => model.rating)         @html.validationmessagefor(model => model.rating)     </div>      <div class="editor-label">         @html.labelfor(model => model.review)     </div>     <div class="editor-field">         @html.editorfor(model => model.review)         @html.validationmessagefor(model => model.review)     </div>      <div class="editor-label">         @html.labelfor(model => model.reviewername)     </div>     <div class="editor-field">         @html.editorfor(model => model.reviewername)         @html.validationmessagefor(model => model.reviewername)     </div>     <p>         <input type="submit" value="create" />     </p> </fieldset> } 

the question is, doing wrong? why validation error generating?

i figured out using suggestion jasen in comments under original post. seems though "review" may have been used twice, although not find where. changed property name "body" , works.

thanks help!


Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -