asp.net mvc - Passing form values from one controller view to another form on a different controllers view in asp MVC -
okay i'm new mvc , trying make me webpage can transfer small form box zip code , button, quote page fill in zip code part on quote page.
my problem have 2 controllers homecontroller has index view small form box. need pass zip code quotecontroller has it's own view populated new zip code.
the home controller input, indexview
@using (html.beginform("quote", "quote")) <p>move zip:</p> <input type="text" name="zip"/><br /> <input type="submit" value="next" name="next">
the quote form receive zip, on quote controller, on quote view
@html.label("move zip ")<br /> @html.textboxfor(m => m.movefromzip, "", new { maxlength = 5, @class = "short-textbox" })
what's easiest way of doing this
in index view of homecontroller, can keep form action "quote/quote"
@using (html.beginform("quote", "quote")) { <input type="text" name="zip" /> <input type="submit" /> }
create view model quote action method view in quotecontroller
public class quotevm { public string zip { set;get; }
and in quotecontroller's quote action method
[httppost] public actionresult quote(quotevm model) { return view(model); }
and quote view be
@model quotevm <p>data passed(posted) index view</p> @using(html.beginform("quotesave","quote")) { @html.textboxfor(s=>s.zip) <input type="submit" /> }
now form submit in view, need have httppost action method
[httppost] public actionresult quotesave(quotevm model) { // : , return }
Comments
Post a Comment