Tag: ASP.NET MVC

Retrieve Data from the Request Object in ASP.NET MVC

In ASP.NET MVC, the Request property defined within the controller can be used to retrieve the data about the request. They can be accessed easily in the controller. Some of the useful properties within the Request objects includes Request.QueryString – This is a NameValueCollection which can be used to access variable sent with this request using GET method. Request.Form – This is a NameValueCollection will…

IController in ASP.NET MVC

Every Controller in ASP.NET MVC is extended from the Controller abstract class which in turn implements the IController interface. The IController interface is defined in the System.Web.Mvc namespace of the .NET Framework. The IController interface contains the method Execute which is called when the user enter the URL which involves the implemented controller class. The controller classes that you create can implement IController but you…

How to Generate Links to Action Method in different Areas in ASP.NET MVC?

The ActionLink helper method has 9+ overloads to generate links based on various scenarios. Generally, the “Action Name” is passed as the 2nd parameter to the ActionLink which points to the current Controller and the specified Action method. What do we do when the Action method of a different Area needs to be refereed to when generating the link in ASP.NET MVC? How to Generate…

RegisterArea in ASP.NET MVC

In the previous article, we provided you an overview of the areas in ASP.NET MVC. When a new area is created in ASP.NET MVC, a file with the area name suffixed by AreaRegistration will be created. In the example as described in the previous article, the AbundantcodePayrollAreaRegistration.cs contains the following This class contains the RegisterArea method which is used to register the route with the…

Creating Areas in ASP.NET MVC Application

The ASP.NET MVC Framework has the concept of “Areas” which allows the developers to organize the functional module of the web application. For Example, the modules like administration, student’s data, exam/test, results can be each area in the Application. The Area in the ASP.NET MVC project has a folder structure which includes controllers, views, Models etc. and allows the developers to keep them separate from…

How to Populate the DropDownList in ASP.NET MVC Razor View?

The DropDownList is one of the most useful controls that can be used in various scenarios that involves selecting the data from the list. The ASP.NET MVC Framework provides the Html.DropDownList and Html.DropDownListFor helper methods which can be used to create DropDownList. How to Populate DropDownList in ASP.NET MVC Razor View? Below is a sample source code demonstrating how to Populate DropDownList in ASP.NET MVC…

CS1502: The best overloaded method match for System.Web.WebPages.WebPageExecutingBase.WriteSystem.Web.WebPages.HelperResult)’ has some invalid arguments Error in ASP.NET MVC

If you are getting the below error message in ASP.NET MVC Web Application, you can resolve it by looking at the methods that renders the partial view in the screen. “Server Error in ‘/’ Application. ——————————————————————————– Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code…

Url.Action in ASP.NET MVC

The Url.Action method in ASP.NET MVC allows the developers to generate the fully qualified URL to an action method. It is defined in the namespace System.Web.Mvc. The Url.Action generates only the URL unlike the Html.ActionLink. Url.Action in ASP.NET MVC Below is a code snippet of the View demonstrating the Url.Action

How to Specify CSS Class Name for the ActionLink in ASP.NET MVC?

Below is a sample soucrecode demonstrating how to specify the CSS class Name for the ActionLink helper method in ASP.NET MVC. How to Specify CSS Class Name for the ActionLink in ASP.NET MVC? @model MvcApplication1.Models.EmployeeVM @{ if (@ViewContext.ViewData.ModelState.IsValid) { ViewBag.Title = “Index”; } } <h2>Abundant Code</h2> @Html.ActionLink(“Abundantcode.com – Primary source for Programming samples”, “Home”, new { @class = “Style1” })

Liked this content?. Please spread the word :)