asp.net-mvc


how to return to filled out form from other view in mvc


I am not very experienced in programming, so I apologize in advance if this is a very obvious question.
I have a form in which the user types in his information. It is validated in the HttpPost then sent to another page where the contact information are shown so the user can check, if everything is in order.
if not there is a button for going back to the previous form to correct this.
Problem: Everything works perfect, except the going back for correction.
How can I go back to the filled out form?
Below is my code so far:
Index-Controller:
public ActionResult DefaultForm(QuestionViewModel viewModel)
{
//method i wrote for populating the 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 are the start and end in the 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 i need to add more code or information to the question, please tell me.
You could place an extra method in your controller where you create an instance of your model and populate it with the information, then use that model to show the details, if you need to correct them, simply call the "New" page and pass that model. If you don't need to correct anything, use the model to persist the data.
Or an easier way, you could try with javascript:
Go back

Related Links

Orchard Projections & Collapse Accordion
converting existing website to multilingual website of asp.net mvc
ASP.NET MVC2 slow after re-compilation
MVC equivalent of jQuery.load
mvc 4 I've deployed to production server. Now cannot connect to localdb
Extra Paging Section at the Top of Kendo UI Grid using Razor
MVC 5- Application showing error message for System.Web.WebPages.Html.HtmlHelper for controls like viewbag
How to get custom date [only YYYY] validated MVC razor?
MVC Survey and capturing data
ReadOnly Form Properties
Add string prefix to automapped model property
MVC 4.0 Clearing output cache using HttpResponse.RemoveOutputCacheItem
How to disable open ASP.NET MVC site in IFrame?
Index ActionMethod in Home Controller would be called twice in ASP.Net MVC
how to determine if page is using http or https in a view?
Azure MVC4 RequireHttps not redirecting to https site

Categories

HOME
gwt
parse.com
jsonschema
prebuild
amazon-kinesis
gluu
tsql
vsix
delphi-xe7
documentation
akka.net
jena
intl
avplayer
tapi
numericupdown
cloudrail
pyfftw
export-to-excel
lazy-loading
durandal-2.0
gas
collision
advantage-database-server
realm-java
eonasdan-datetimepicker
ratchet-2
shape
addthis
spring-batch-admin
jtable
apscheduler
monads
dashboard-designer
tensor
spring-data-cassandra
presto
mask
confirm
msal
apartment-gem
extjs4
es6-promise
sweet.js
maven-jetty-plugin
openwebanalytics
multisite
ctl
okular
replaygain
complement
canopen
kony
fasta
assembly-references
ipmi
turbo-c
android-sdk-tools
wxhaskell
mink
jasny-bootstrap
webclient-download
visual-build-professional
dms
uploadify
yapdatabase
parsoid
clientid
aldryn
jedi
pyenchant
oboe.js
telescope
translate3d
smarty2
iife
newsql
isql
gcovr
liferay-hook
express-jwt
eventmachine
cellular-automata
declspec
showcaseview
gora
xcode4.2
datadesign
hudson-plugins
file-structure
documentviewer
asp.net-session
hpple
jammit
facebook-authentication
textboxlist
xmltextwriter
directoryentry
pastebin
seam-conversation
chickenfoot
development-machine
crc-cards
user-testing

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App