filmov
tv
Part 12 Creating a view to insert data using mvc

Показать описание
Text version of the video
Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.
Slides
All ASP .NET MVC Text Articles
All ASP .NET MVC Slides
All Dot Net and SQL Server Tutorials in English
All Dot Net and SQL Server Tutorials in Arabic
In this video we will discuss, creating a view to insert a new employee into the database table tblEmployee. Please watch Part 11, before proceeding with this video.
We want to present the end user with a form to enter data.
Copy and paste the following "Create" action method, in EmployeeController class.
[HttpGet]
public ActionResult Create()
{
return View();
}
Please note that, the method is decorated with "HttpGet" attribute. This makes this action method to respond only to the "GET" request.
Now let's add a "Create" view. To do this, right click on the "Create" action method and select "Add View" from the context menu. Set
1. View name = "Create"
2. View engine = "Razor"
3. Select "Create Strongly-typed view checkbox
4. Select "Employee" class, from "Model class" dropdownlist
5. Scaffold Template = Create
6. Click "Add" button
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
Run the application and navigate to the following URL
Click on "Create New" link. You will be naviaged to the following URL
A form with textboxes to add a new employee is rendered. For employee "Gender" it is ideal to have a dropdownlist instead of a text box.
Run the application and notice that, a dropdownlist is now displayed for "Gender".
If you click on "Create" button, you will get an error message stating - The resource cannot be found. This is because we donot have the "Create" controller action method that can handle HTTPPost request. We will discuss fixing this in our next video.
Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.
Slides
All ASP .NET MVC Text Articles
All ASP .NET MVC Slides
All Dot Net and SQL Server Tutorials in English
All Dot Net and SQL Server Tutorials in Arabic
In this video we will discuss, creating a view to insert a new employee into the database table tblEmployee. Please watch Part 11, before proceeding with this video.
We want to present the end user with a form to enter data.
Copy and paste the following "Create" action method, in EmployeeController class.
[HttpGet]
public ActionResult Create()
{
return View();
}
Please note that, the method is decorated with "HttpGet" attribute. This makes this action method to respond only to the "GET" request.
Now let's add a "Create" view. To do this, right click on the "Create" action method and select "Add View" from the context menu. Set
1. View name = "Create"
2. View engine = "Razor"
3. Select "Create Strongly-typed view checkbox
4. Select "Employee" class, from "Model class" dropdownlist
5. Scaffold Template = Create
6. Click "Add" button
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
Run the application and navigate to the following URL
Click on "Create New" link. You will be naviaged to the following URL
A form with textboxes to add a new employee is rendered. For employee "Gender" it is ideal to have a dropdownlist instead of a text box.
Run the application and notice that, a dropdownlist is now displayed for "Gender".
If you click on "Create" button, you will get an error message stating - The resource cannot be found. This is because we donot have the "Create" controller action method that can handle HTTPPost request. We will discuss fixing this in our next video.
Комментарии