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.

Basic Login page using Asp.Net MVC 2

In this post we shall create a simple Login page using 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.

The login page will have the controls User Name and Password, and the buttons Login and Cancel. When the user types the username and password, it should validate the details against the model and display an appropriate message.

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