0

I am new to MVC3. I am using razor.

I have a menu with 4 items. With each click, a different partial view should open.

Could anyone help me out here..

Preferably, without using a controller on server side..

Thanks, Aneesh

1
  • You should provide more information about what are you trying to accomplish. Do you want to dynamically load those views via ajax for example? Commented Jun 5, 2012 at 12:03

2 Answers 2

4

Html.RenderPartial is what you need if you don't what to use a controller:

http://msdn.microsoft.com/en-us/library/system.web.mvc.html.renderpartialextensions.renderpartial.aspx

If you want to render partial view using controller action then use Html.RenderAction: http://msdn.microsoft.com/en-us/library/system.web.mvc.html.childactionextensions.renderaction.aspx

http://devlicio.us/blogs/derik_whittaker/archive/2008/11/24/renderpartial-vs-renderaction.aspx

Sign up to request clarification or add additional context in comments.

Comments

0

You have to create an object where all the data that you want show on the all the different partial views. Then use @Html.RenderPartial to render your desired partial. Use the second parmater to add the data.

Example: @{Html.RenderPartial("_Customers", Model.CustomerList);}

1 Comment

This example is invalid. Proper use: @{Html.RenderPartial("_Customers", Model.CustomerList);}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.