Geeks With Blogs
Bala's Weblog The programmer's space. January 2014 Entries
How to insert data into the ASP.NET MVC.
There are multiple ways to insert the data into the database. like Form collections, parameter based,model binders. Here I use employee controller which has two action methods one is Display the list the employees and the other will insert the employee item. Create – HTTP Get:- Once the user clicks the Create button the create action method will execute. It morphes to the HTTP Get request. [HttpGet] [ActionName("Create")] public ActionResult Create_get() { return View(); } The view will display the ......

Posted On Thursday, January 30, 2014 11:45 PM

Business Objects as models in ASP.NET MVC
In all the earlier we use Entity Framework as models in the MVC application Now we are going to use Business objects as models in asp.net mvc. the data layer ca be exposed using ADO.NET objects. So in ASP.NET MVC the controlller will search for views in particular folders and it is not dependent to the models. Here in this application I used the Business Layer & Data Access Layer for models to access the DB. The solutions will display the list of department. The project structure looks like. ......

Posted On Thursday, January 30, 2014 11:17 PM

Working with Multiple Controllers in ASP.NET MVC
So far in the above posts we seen for only one controller class and multiple action methods. Now in this post we are going to see for multiple controller. How the requests are routing to the appropriate controllers. In the sample post I have two controllers one is AssociateController and other is Department controller. Department controller has list of departments and navigation of associates in the selected department action methods. Associate controller has list of associates and single associate ......

Posted On Thursday, January 30, 2014 1:30 PM

Generate Hyperlink using ActionLink HTML Helper in ASP.NET MVC.
In this blog post we are going to see the ASP.NET MVC List & Details section in the views. This will enables the dynamic hyperlink to certain elements in the page. This is example for the ASP.NET page for List and Details view and the hyperlink creation and use. 1. Create a Modal with database table. eg: Employee modal and the EmployeeContext class. [Table("Employee",Schema="H... public class Employee { [Key] public int BusinessEntityId { get; set; } public string NationalIdNumber ......

Posted On Wednesday, January 22, 2014 2:09 AM

Access SQL Data from the ASP.Net Application.
This is a sample ASP.NET application which displays the data from the SQL Server North Wind database in the web page. Defining Entity Framework: * Check whether the Entity Framework is installed else install through the Nuget package manager. Adding a modal class * Add the new Modal class. The modal class should be as similar the table that we have in the database. for eg: I have created a Employee class for the HumanResources.Employee table in the DB. [Table("Employee", Schema = "HumanResources")] ......

Posted On Wednesday, January 22, 2014 1:44 AM

Explain ASP.NET Model in detail?
The controller responds to the url request, get the data from a model and hands it over to the view. the view can render the data.Models can be entities or business data. Display datatable in the view controller and gets the data from the model and display in the view. Model is typed object as like the database. You can use the model in the views @Model.EmployeeId. Example for Model:- Controller Class: public ActionResult Display() { Employee emp = new Employee() { EmployeeId =1,EmployeeName ="test",Designation ......

Posted On Thursday, January 16, 2014 3:37 AM

How can we pass data from Controllers to the Views.?
We can pass data from controller to view by viewbags, viewdata, viewmodel. ViewBag Viewbag is dynamic which works in C# 4.0 and above. where we can store any key value pair variables. ViewBag doesn’t require typecasting for complex data type. eg: ViewBag.var1 = "test1"; In Views we can use the display as @ViewBag.var1 ViewData Viewdata is dictionary object where we can store any dictionary or array of objects.ViewData requires typecasting for complex data type and check for null values to avoid error. ......

Posted On Thursday, January 16, 2014 3:13 AM

Asp.Net MVC Views in detail.
ASP.NET MVC view will get the request from the controller action method and rendered to the browser. Each controller action methods has an view. Example: Each controller action method can return an ActionResult ()or ViewResult() object. public ActionResult index() { return view() } Sample Controller Action Methods:- public ActionResult Companies() { ViewBag.Companies = new List<string>() { "Cognizant","TCS","HCL","Wi... }; return View(); } public ViewResult State() { ViewBag.States ......

Posted On Thursday, January 16, 2014 1:40 AM

Asp.NET MVC Controller in detail
What is controller? Controller handles all the input ASP.NET MVC requests in their action methods and process them accordingly.we can have n number of action methods inside each controller serving multiple user requests. Also we can have multiple controller classes. The input requests will be like this format routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } Each route should have name & the ......

Posted On Thursday, January 16, 2014 12:58 AM

My First ASP.NET MVC Project.
My First ASP.NET MVC Project. Today in this blog you can see how you can create my first ASP.NET MVC project and how ASP.NET MVC differs from ASP.NET web forms. All my working examples are attached here as screenshot of visualstudio and posted in http://balaweblog.visualstudio .com to the cloud TFS from microsoft. Creating a webform Let us first create a ASP.NET webform application. Here I have a project named FirstMVC and page Home.aspx. It navigates to the page displayed below Here the http request ......

Posted On Wednesday, January 15, 2014 9:46 PM

Copyright © Balamurugan Alagumalai | Powered by: GeeksWithBlogs.net