asp.net mvc - how to return to filled out form from other view in mvc -


i not experienced in programming, apologize in advance if obvious question.

i have form in user types in information. validated in httppost sent page contact information shown user can check, if in order. if not there button going previous form correct this.

problem: works perfect, except going correction.

how can go filled out form?

below code far:

index-controller:

    public actionresult defaultform(questionviewmodel viewmodel)     {                 //method wrote populating dropdown         dropdownpopulate(viewmodel);         return view(viewmodel);              }      [httppost]     public actionresult defaultform(questionviewmodel viewmodel, string tbbutton)     {         if (modelstate.isvalid)         {             try             {                 if (tbbutton.equals("questsend"))                 {                                return view("verify", viewmodel);                 }                 else if (tbbutton.equals("questupload"))                 {                     return view(viewmodel);                 }                 else                 {                     dropdownpopulate(viewmodel);                     return view("defaultform", viewmodel);                 }             }             catch             {                 dropdownpopulate(viewmodel);                 return view(viewmodel);             }         }         else         {             dropdownpopulate(viewmodel);             return view(viewmodel);         }     } 

verify-controller:

 public actionresult verify(questionviewmodel viewmodel)     {         return view(viewmodel);     }      [httppost]     public actionresult verify(questionviewmodel viewmodel, string tbbutton)     {         #region button verarbeitung          if (tbbutton.equals("questkorr"))             {                 return redirecttoaction("defaultform", viewmodel);             }             else if (tbbutton.equals("questsend"))             {                  return redirecttoaction("someotherpage");             }          #endregion          return view(viewmodel);     } 

those start , end in view: defaultform

@using (html.beginform("defaultform", "questionform", formmethod.post, new { id = "questionform" }))         { <button class="btn btn-default btnusz" type="submit" name="tbbutton" value="questsend">senden</button> 

verify:

@using (html.beginform("verify", "questionform", formmethod.post, new { id = "verifyform" }))         { <button class="btn btn-default btnusz" type="submit" name="tbbutton" value="questkorr">korrigieren</button> <button class="btn btn-default btnusz" type="submit" name="tbbutton" value="questsend">senden</button> 

if need add more code or information question, please tell me.

you place method in controller create instance of model , populate information, use model show details, if need correct them, call "new" page , pass model. if don't need correct anything, use model persist data.

or easier way, try javascript:

<a href="##" onclick="history.go(-1); return false;">go back</a> 

Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -