MVC

What are partial views in MVC?

Hi All, Partial view is a reusable view which can be embedded inside other view.Like a user control it can be used in different areas of a page. It can used with left menu, header and footer as shown in the image below. Once the partial view is created we can call the partial view… Read More »

Posted in MVC | Tagged | Leave a comment

Routing in MVC?

Hi All, Routing helps us to give user friendly URL structure. Helps to map those URL structure to the controller.When any user types “http://localhost/View/ViewStudent/” , it will goes to the “Customer” Controller and invokes “DisplayStudent” action. This is defined by adding an entry in to the “routes” collection using the “maproute” function.

Posted in MVC | Tagged , | Leave a comment

What is the difference between tempdata , viewdata and viewbag?

Temp data: Helps to maintain data when you move from one controller to other controller or from one action to other action. In other words when you redirect,“tempdata” helps to maintain data between those redirects. It internally uses session variables. View data: Helps to maintain data when you move from controller to view. View Bag: … Read More »

Posted in MVC | Tagged | Leave a comment

How can we restrict MVC actions to be invoked only by GET or POST?

Hi Friends, We can decorate the MVC action by “HttpGet” or “HttpPost” attribute to restrict the type of HTTP calls. For instance you can see in the below code snippet the “DisplayCustomer” action can only be invoked by “HttpGet”. If we try to make Http post on “DisplayCustomer” it will throw an error.    

Posted in MVC | Tagged | Leave a comment

How can we navigate from one view to other view using hyperlink?

Hi All, By using ActionLink method as shown in the below . The below code will create a simple URL which help to navigate to the Home controller and invoke the GotoHome action

Posted in MVC | Tagged | Leave a comment

Explain the brief history of ASP.NET MVC?

Hi friends, I have gone through some existing features of MVC in its history. MVC Framework have too many features and in each release they have added new features. ASP.NET MVC1 MVC1 was Released on Mar 13, 2009 Runs on .NET 3.5 Runs in Visual Studio 2008 & Visual Studio 2008 SP1 MVC Pattern architecture… Read More »

Posted in ASP, C#, MVC | Tagged , | Leave a comment

Microsoft Unity in Web Applications

The Unity Application Block (Unity) is a lightweight container for dependency injection. Using DI frameworks developers can generate and assemble instances of custom classes and objects that can contain dependent object instances and settings. 1. Constructor injection 2. Method call injection 3. Property injection It helps developers with the following features : Simplifies code Specify… Read More »

Posted in ASP, C#, MVC | Tagged , | Leave a comment

What is MVC ?

MVC is an architectural pattern. It separates the representation and the user interaction in an Application. In MVC there are three important sections. Model,View and Controller. Please see details below. View is responsible for look and feel. Model provides data to the View. Controller is responsible to take the end user request and load the… Read More »

Posted in ASP, C#, MVC | Tagged , , | Leave a comment

DTO (Data Transfer objects) in C#

DTO (Data Transfer objects) is a container for passing data between layers. DTO’s are also termed as transfer objects. DTO is used to pass data and does not contain any business logic in it. Setters and Getters are used in DTO.

Posted in ADO NET, ASP, C#, MVC | Tagged , , | Leave a comment

How to show and hide sections in MVC application according to Model value ?

Hi All, We can show/hide sections in MVC application using following steps. Step 1 : Add following class in CSS Step 2 : Check model value and set variable with CSS class name accordingly Step 3 : Add @showActive as class in place where you want to show/hide sections according to the value of StudentID

Posted in C#, MVC | Tagged , | Leave a comment