Partial View in MVC

Share the joy
  •  
  •  
  •  
  •  
  •  
  •  
  •  

In MVC we use partial view same as we use user control in case of .net.

Partial view are those which dont’  have layout in it or which have Layout=null . made partial view once and use it anywhere in the application by just call it.

Syntax:

View 

{

@Html.action(actionName, Controller);    //to call the partial view in your main view.

}

Controller

{

public ActionResult actionName()

{—————some code—————————-

var model = GetModel(); //utility to get values for model

return PartialView(model);

}

//utility

protected IList<RegisterCustomerModel> GetModel()

{

var report = new RegisterCustomerModel();

//—–fill the model using services

//—————-some coding———-

return report;

}

}

 


Share the joy
  •  
  •  
  •  
  •  
  •  
  •  
  •  

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.