Hi All i am new to this mvc. I have a small question in mvc4?
I want to add a controll and i want to write the Create,Update,Delete all methods in controller and i want to generate the views manually not like scaffholding. and i want to do all the operations in same view , not like creteview,updateview,delete view..is that possible...hi
how to identifie wheather the action method is create,update,delete..e.c.t..
regards
lvprasad
Loading

Guest UserPosted Aug 20, 2014, 6:50 AM
R JPosted Aug 19, 2014, 6:33 PM
Simply write ActionMethod with somename in the controller and return view ("viewname") like
Public ActionResult MyActionMethod()
{
////// your logic
return View("myViewname");
}
optionally you can do this way, follow the steps.
1. Create empty controller.
2. Write ActionMethod same as above code
3. Now RightClick on "MyActionMethod", you will see option called "AddView", it will create the View for your action method and right structured folders.
Now you can write your code in "myViewname" view file. Let me know if you still need any help, thanks.
lv prasadPosted Aug 19, 2014, 6:05 PM
my requirement is i will take an empty index , and i will design manually like
Name
and after that i will write individual method for saving and updating and deleting..by taking a sample controller...is this possible..we can do this...is this recommended...or every time we need to go with Scaffholding template...guide me..
Guest UserPosted Aug 19, 2014, 12:08 AM
- create a new project and pick MVC4 then pick Intranet or Internet application
- It'll scaffold the project with default settings
- If you look at controllers, e.g., HomeController you'll find below:
[HttpGet], [HttpPost], [HttpPut], [HttpDelete]
Now MVC is mapped with action verbs, so
GET -> select
POST -> Insert
PUT -> Update
DELTE -> Delete
And all of these controller methods then correpond to View which to render.
I hope it's clear to you now.
Please accept answer if you find it helpful!