This project is read-only.

Embed View in another View

Jan 24, 2012 at 10:01 AM
Edited Jan 24, 2012 at 10:05 AM


I would like to show view in another view.

I have created a view (Logon) in ClassLibrary and trying to display in another view (Employee) which is in web application project.

I am able to see the logon screen if I access it directly like http://localhost/Account/Logon But I would like to display the same screen in a DIV in some view.

I am using RenderPartial to display the view : @{Html.Partial("Logon");}

Bu I am getting following error: "The partial view 'Logon' was not found or no view engine supports the searched locations. The following locations were searched:".

I have registered views in Global.asax

 Can you let me know how to achieve this? 

Jan 24, 2012 at 5:57 PM

Normally, anything that works in a regular MVC app should work with the generator. e.g. if you take a default MVC3 app and enable the generator on all views, it works fine for _LogOnPartial.cshtml, which is used from the Layout page using @Html.Partial("_LogOnPartial").

Not sure what's different in your app, but you may want to start with a default MVC app and try to isolate the difference from there.

Jan 25, 2012 at 4:24 AM

Yes, as you said it should work. I am using default MVC app only i.e., Logon view.

Anyhow, for now @{Html.RenderAction("Logon","Account");} is working instead of RenderPartial. I am trying to find why RenderPartial isn't working.

Thanks for the quick response.