Showing posts with label Asp.Net MVC. Show all posts
Showing posts with label Asp.Net MVC. Show all posts

Sunday, April 10, 2016

Html.RenderAction Vs Html.Action

Both Html.RenderAction and Html.Action can be used to call an Action method and render output of the action method as embedded content in the main view, they can be used to display content in a part of the main view page like user controls.

In this post we shall see the difference between these and the scenarios where to use each of these.

Asp.net MVC 2 Url.Action example

Asp.Net MVC offers 2 ways of adding Hyperlinks in a page.

1. Using the Html.ActionLink method
2. Using the Url.Action method

In this post we shall see on how to add Hyperliks to a View page using Url.Action. The Url.Action just returns the URL for the specified controller and action, hence while using the Url.Action method we need to explicitly form the tags and text around the Hyperlink as follows.

Asp.net MVC 2 Html.ActionLink example

Asp.Net MVC offers 2 ways of adding Hyperlinks in a page.

1. Using the Html.ActionLink method
2. Using the Url.Action method

In this post we shall see on how to add Hyperliks to a View page using Html.ActionLink. The Html.ActionLink method generates an  <a href=””> tag and places in the page.

The simplest form of Html.ActionLink, takes the Link Name and the Action Method name and the Controller name as parameters, if the controller name is not provided it takes the Home controller

Html.ActionLink and Url.Action in an Asp.Net MVC 2

Hyperlinks are a common requirement in any webpage, in general we use the <a href> tag to create hyperlinks from one page to another, Asp.Net MVC still allows this type of hyperlinks in addition it provides 2 other ways of adding Hyperlinks in a page.

Asp.Net MVC Set Startup Page

In Asp.Net Web Farms we set the startup page by just right clicking the page and selecting Set as Startup Page, however in Asp.Net MVC Applications we need to set this in the Global.asax.cs file. In this post we shall see on how to configure the default start up page for an Asp.Net MVC Application.

Thursday, March 31, 2016

User List Page using Asp.Net MVC 2

In this post we shall create a simple User List page using Asp.Net MVC 2. We will make use of the Empty Web Application template to create this sample so that we will understand the basics of MVC.

The User List page will display a list of users in a Table. The List object containing the list of users will be passed from the Controller to the View, the View loops through the users and displays the user details in Table.

User Registration Page using Asp.Net MVC 2

In this post we shall create a simple User Registration page using Asp.Net MVC 2 Application. We will make use of the Empty Web Application template to create this sample so that we will understand the basics of MVC.

The Registration page will have the controls Name, Age, Address, etc and the buttons Save and Cancel. When the user enters the details and click Save, it should validate the details and pass on the same to the Model.

Tuesday, March 29, 2016

Hello World MVC Application

In this post we shall create a Hello World Asp.Net MVC 2 Application from the scratch. We will make use of the Empty Web Application template to create this sample so that we will understand the basics of MVC. Follow the below steps to create the first MVC 2 Hello World Application

Tuesday, December 11, 2012

What's New in ASP.NET MVC4

The feature additions in Asp.Net MVC4 are relatively less when compared to the MVC2 – MVC3 upgrade. Asp.Net MVC4 mainly focuses on mobile web development, in addition it adds a few features to the existing Web application projects.


1. Includes support for Asp.Net Web API

What's New in ASP.NET MVC3

Asp.Net MVC3 has brought in a whole lot of features, which help in improved productivity, performance, scalability and security. 


Asp.Net MVC3 is the successor of Asp.Net MVC2, it requires .Net Framework 4.0 or higher and is compatible with
Visual Studio 2010 or higher. We shall see some of the key feature additions to Asp.Net MVC3 in this post.

1. Introduction of Razor view engine

Wednesday, December 5, 2012

Asp.Net MVC Application Project Templates

Visual Studio 2008/2010, provides 2 templates for creating Asp.Net MVC Applications.
          Asp.Net MVC Web Application
          Asp.Net MVC Empty Web Application

Asp.Net MVC Web Application

The Asp.Net MVC Web Application template creates a project with a set of pre-defined files which are ready to run, this template will give a sample set of files on top of which the users can create additional files.

Asp.net MVC Vs Web Farms Application

Asp.Net MVC is not a replacement for the Web Forms model of Asp.net application, each has its own advantages and disadvantages, it is up to the user to decide on which model to user based on the requirements and other factors.

In this post we shall compare the features of Asp.Net MVC Applications and Web Farms Application

ASP.NET MVC - The Controller

As the name suggests the Controller is the one which controls the execution of the entire application, all requests to the applications are handled by the controller, once the controller receives the request it decided the model to be called, and the View to be invoked to render the output to the Browser.

A Model is a .vb or .cs class, Controller classes should end with the word “Controller” example EmployeeController, DepartmentController etc. The controller contains a set of Action methods, each of which is mapped to a specific request from the user.

ASP.NET MVC - The View

The View is the UI part of the MVC Architecture, the View is fully responsible for what the user sees in the browser, all UI aspects like controls, color, style, formatting etc are taken care of by the View.
The View defines the style and formatting aspects of the display and embeds the data provided by the model to produce a page which has meaningful information.

A View is an .aspx file, The Name of the View should match the name of the function in the controller which handles the View. For example a view with the name LogOn should have a matching method in the controller which handles requests for this View.

The Controller receives the request from the user and invokes the corresponding view, the view in turn makes use of the data from the Model and renders the page to the user in the browser.

ASP.NET MVC - The Model

The Model represents the data engine of the MVC architecture, the Model holds the data to be rendered to the UI, the View makes use of the data in the model and binds it appropriately in the Page to display data in the browser. The Model is also responsible for retrieving the data from and saving the data back to the underlying database.

A Model is a .vb or .cs class, Model classes should end with the word “Model” example EmployeeModel, DepartmentModel etc.

The Model class is accessible by both the View and the Controller; the data provided by the Model is used by the view to render information to the user in the browser. The View defines the style and formatting aspects of the display and embeds the data provided by the model to produce a page which has meaningful information.

ASP.NET MVC Architecture

The Asp.Net MVC architecture focuses on separating the UI design and the implementation logic, and thereby improves testability of the application.

The Architecture of Asp.Net MVC makes it possible to make use of advanced client side scripting concepts like JavaScript and jQuery. The Web Forms Architecture also supports JavaScript and jQuery but they don’t mingle well together, the Asp.Net MVC Architecture overcomes this issue and co-ordinates fully with JavaScript, jQuery and other client side scripting frameworks.

MVC stands for

ASP.NET MVC3 Prerequisite

An Asp.Net MVC3 Application need the following minimum requirements.

.NET Framework 4
 ASP.NET 4
 Visual Studio 2010 or Visual Web Developer 2010

Supported Operating Systems:
 

ASP.NET MVC2 Prerequisite


An Asp.Net MVC2 Application need the following minimum requirements.

.Net Framework 3.5
Visual Studio 2008
Visual Studio 2008 SP1 or Visual Web Developer 2008 SP1

Supported Operating Systems: 

Asp.Net MVC Overview

Asp.Net MVC is one of the models provide by Asp.Net to build web applications, this model is based on the MVC (Model View Controller) design pattern. This model focuses in separating the design from the implementation logic, and is aptly applicable where intense testing is required in each of the blocks (design, logic and data access). Since this model separates design and implementation logic, it makes it possible to test each of these blocks individually.