Asp.Net MVC Not Duplicate forms when Edit/Add

Asp.Net MVC Not Duplicate forms when Edit/Add

When we have anything that requires user input (Eg adding a product to a database) the Edit screen looks the same as the add screen. When using MVC .Net how do you handle this? Do you return the same view? Just adjust the model to reflect the change?

Facebook IFrame Application issues for certain users


programmatically logout a “specific” user

Same (partial)view

You create only one although strong typed view (depending on the UI it must of course be a partial view as well). mvc html melperWhen adding new data return this view from controller action with default model object instance (usually just a new instance without any properties being set), although when you edit, return it with the object instance this you'd like to edit.. Proper way to build a data Repository in ASP.NET MVC

Controller part

Regarding controller actions you must have four of them:. Why use TagBuilder instead of StringBuilder?
  1. Add GETDifference between HtmlTable and TagBuilder(“table”) return View("SomeView", new Customer());
  2. Add POST
  3. Edit GETDetect whether or not a specific attribute was valid on the model return View("SomeView", new CustomerRepository().GetCustomer(id));
  4. Edit POST
Bot GET actions return the same view although with different model as described earlier. How to get parameters out of an ascx back to the main aspx pagePOST actions both store submitted data, although return whatever they need to. Probably any RedirectToAction()....


You must use the same view for display and Edit, simply call it from your controller .
return View("ViewName") 


You could have the form fields in a partial view and have two separate views using the same partial view, one posting to the edit controller action method and the another posting to the add controller action method..


Partial views are used to remove duplicity. You could read an case of this in the Nerd Dinner tutorial..

50 out of 100 based on 65 user ratings 460 reviews