1

It was suggested on my Stack Overflow question that this might be better suited to this site, so I'm cross-posting it.

I'm working on my first ground-up build of an MVC site. I have a collection of views, a collection of models, and I've tested most of my views and fixed the obvious bugs.

The last step I need to do is tie the views together - to enable the user to click links/buttons and move between them.

Most of my Google searches for Actions and ActionLinks in MVC/Razor lead me back to StackOverflow, to very specific questions which don't really help me out - the questions assume what I'm trying to learn.

I'm trying to learn at a high level the way to pass various things to controller methods (i.e. override the controller method for a view to accept 2 parameters versus 3, or to accept POST data, understand what will be passed along from one view to another action from an Html.Action call, etc).

  • 4
    Cross posting between Stack Exchange sites is frowned upon - better to flag the question & let a moderator move it. (Not a big deal, just something to know for next time) – Dan Pichelman Jul 12 '13 at 18:37
  • @DanPichelman - nothing lost in this case as the SO version doesn't have any answers. – ChrisF Jul 12 '13 at 21:44
2

I don't know if you have had the chance to read ASP.NET's Intro to MVC or not, but that is what I used to get started on linking one view to another and back. If your controllers use parameters, but you want some (or all) of them to be optional and you send data back and forth, you can use optional parameters.

As far as posting data, that really depends on how you roll it up and send it off. My personal opinion is to roll it into JSON and play with it from there. MVC's JsonAction works beautifully for that. An alternative that I may be beaten for even suggesting, would be to use the ViewBag to pass minor amounts data around. It works in a pinch, but there are safer and more robust ways to move data around for manipulation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.