Passing Parameters to the ActionLink in ASP.NET MVC

Published on April 23, 2013 by abundantcode

Filed under ASP.NET

Last modified April 23, 2013

Print this page

rate 1 star rate 2 star rate 3 star rate 4 star rate 5 star
Your rating: none, Average: 0 (0 votes)

This article have been viewed 7833 times

There are times when the parameter has to be passed along with the URL from an ActionLink control in ASP.NET MVC. This can be done easily using the anonymous type which can be passed as the third parameter for the ActionLink helper method.

Passing Parameters to the ActionLink in ASP.NET MVC

Below is a sample code snippet demonstrating how to pass values to the ActionLink in ASP.NET MVC

@model MvcApplication1.Models.EmployeeVM

@{

if (@ViewContext.ViewData.ModelState.IsValid)

{

ViewBag.Title = "Index";

}

}

<h2>@ViewBag.ApplicationTitle</h2>

@Html.ActionLink(“Abundantcode.com – Primary source for Programming samples”,”Home”, new { id = “Welcome to Abundantcode.com” })

Leave a Comment


x

You might be Interested in these Posts

How to read connection string from web.config in ASP.NET and C# ?

Here's a sample code snippet demonstrating how to get the connection string from your ASP.NET web.co...

How to return Json instead of XML in ASP.NET Web API ?

When you make a call to the ASP.NET Web API action method and notice this in Google Chrome browser ,...

How to Add Web API to existing ASP.NET Web Forms Project ?

In one of the previous posts , we saw how to add the WebAPI to the existing ASP.NET MVC project. Wel...