asp.net mvc - MVC 3 - Posting partial view to a chosen controller -


i'm trying learn mvc 3 , razor coming asp.net background.

i've want simple partial view (in shared folder) post specific controller can re-use elsewhere such articles, blogs etc. tried using variations of following.

@using (html.beginform("create", "comment", formmethod.post,  new { })) {     <div>         <fieldset>             <legend>comments</legend>              <div >                 @html.labelfor(m => m.name)                 @html.textboxfor(m => m.name)                           </div>              <div >                 @html.labelfor(m => m.email)                 @html.textboxfor(m => m.email)                           </div>              <div >                 @html.labelfor(m => m.body)                 @html.textboxfor(m => m.body)                           </div>              <p>                 <input type="submit" value="create" />             </p>         </fieldset>     </div> } 

this doesn't post comments controller action create shown below.

[httppost] public actionresult create() {     // save comment code here      return view(); } 

there simple way of doing without having bound specfic route?

i found answer.

@using (ajax.beginform("create", "comment",  new ajaxoptions() {         updatetargetid = "maincontainer"    }))  {       <div>         <fieldset>             <legend>comments</legend>              <div >                 @html.labelfor(m => m.name)                 @html.textboxfor(m => m.name)                           </div>              <div >                 @html.labelfor(m => m.email)                 @html.textboxfor(m => m.email)                           </div>              <div >                 @html.labelfor(m => m.body)                 @html.textboxfor(m => m.body)                           </div>              <p>                 <input type="submit" value="create" />             </p>         </fieldset>     </div> } 

this posts using ajax , doesn't change url. or can way using jquery http://jvance.com/blog/2010/02/20/makinganajaxformwithjqueryinaspdotnetmvc.xhtml


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -