asp.net mvc - @Html.Action post state model not doesn't affect partialview -


in bookscontroller

    [childactiononly]     public actionresult commentform(int bookid)     {         var model = new commentsurrogate();         model.bookid = bookid;         model.date = datetime.now;         return partialview("_commentform", model);     }       [httppost]     [childactiononly]     public actionresult commentform(commentsurrogate model)     {         if (modelstate.isvalid)         {             if (session["commentsec"] string == model.securitycode)             {                 model.date = datetime.now;                 commentrepository repo = new commentrepository();                 repo.save(model);                 viewbag.commentmessage = "yorumunuz başarıyla kaydedilmiştir. editörlerimiz tarafından incelenip onaylandıktan sonra yayınlanacaktır.";                 return partialview("_commentform", new commentsurrogate {date = datetime.now, bookid= model.bookid });             }             else                 modelstate.addmodelerror("securitycode","güvenlik kodunu yanlış girdiniz.");         }         return partialview("_commentform", model);     } 

in bookdetailview

@html.action("commentform", "books", new { bookid = model.id }) 

when write comment , post using comment form. calling commentform action [httppost] attribute. , im saving model, no problem @ time.

return partialview("_commentform", new commentsurrogate {date = datetime.now, bookid= model.bookid }); 

but _commentform seems not have retrived new commentsurrogate model has passed code above. after post action comment form still has data of current posted data.

_commentform.cshtml

@model yayinevi.data.surrogates.commentsurrogate @using (html.beginform()){ @html.antiforgerytoken() <div id="respond" class="clearfix">      <div class="title-block" style="margin: 0 0 30px 0;">         <h3>kitap hakkında yorum yazın</h3>     </div>     @if (@viewbag.commentmessage != null)     {         <div class="msg success"><p>@viewbag.commentmessage</p></div>     }     @html.hiddenfor(model => model.bookid)     @html.validationsummary(true, "", new { @class = "text-danger" })     <div class="field-row">         @html.labelfor(model => model.name)         @html.editorfor(model => model.name, new { htmlattributes = new { @class = "text_input" } })         @html.validationmessagefor(model => model.name, "", new { @class = "text-danger", style = "display:block;margin-top:-20px;margin-bottom:15px;" })     </div>     <div class="field-row">         @html.labelfor(model => model.email)         @html.editorfor(model => model.email, new { htmlattributes = new { @class = "text_input" } })         @html.validationmessagefor(model => model.email, "", new { @class = "text-danger", style = "display:block;margin-top:-20px;margin-bottom:15px;" })     </div>     <div class="field-row">         @html.labelfor(model => model.comment)         @html.textareafor(model => model.comment, new { htmlattributes = new { @class = "text_input", cols = "60", rows = "9" } })         @html.validationmessagefor(model => model.comment, "", new { @class = "text-danger", style = "display:block;margin-top:-20px;margin-bottom:15px;" })     </div>     <div class="field-row">         @html.labelfor(model => model.securitycode)         <img style="vertical-align:middle;" src="@(url.action("captcha", "layout", new { sessionname="commentsec"}))" /> <br />@html.editorfor(model => model.securitycode, new { htmlattributes = new { @class = "text_input" } })         @html.validationmessagefor(model => model.securitycode, "", new { @class = "text-danger", style = "display:block;margin-top:-20px;margin-bottom:15px;" })     </div>     <input class="button1" type="submit" value="gönder" id="submit" name="submit"> </div> } 


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -