Using Dalegates in ASP.NET MVC

Introduction: We know that MVC is a integrated modules; that name is the models,views and controlers. ASP.NET MVC is the new version of ASP.NET. In this application we will learn about how to use a delegate in an ASP.NET MVC application to develope a simple module. ASP.NET MVC gives you a powerful, patterns-based way to build dynamic websites that enables a clean separation of concerns and that gives you full control over markup for enjoyable, agile development. The controllers in an ASP.NET MVC application control the flow of application execution. Models is provide a business logic and views is provide a representation of data. This is a simple application for beginners that helps with how to create a delegate in an ASP.NET MVC application. Some types of Web applications will benefit from the MVC framework. Others will continue to use the traditional ASP.NET application pattern that is based on Web Forms and postbacks.

Step 1: Open Visual Studio 2010.

  • Click file ->New->Projects
  • Add MVC ASP. NET 2 Empty Web application
  • The application name is "manish"
newapp.gif
start.gif

Step 2: Add the class in a program.

  • Right Click on the Models folder
  • Add->Add new items->add class
  • Class name is "sandeep"

openmodel.gif

addclass.gif

Code:

clacode.gif

Step 3: Add a controller.

  • Right Click on the controllers folder
  • Add->controller
  • Controller name is "bhanu"
addcontroller.gif

controller.gif

Code:

classcode.gif

Step 4: Add views.

  • Right Click on the Action result object
  • Add view
  • View name is "Index"
  • Tick a checkbox and create a strong type view
view.gif
addview11.gif

Step 5:
Write the code in the index view.

Code:

vieecode.gif

viewcode.gif

Step 6: Press crtl+f5 to run the program.

Output:

output.gif


Similar Articles