Click here to Skip to main content
15,909,445 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,
i have to insert the cshtml page in to the div containing id=main. I used jquery load method to add the cshtml page but not working...

sample code:

$("#main1").load('sample.cshtml');

Any body help me thanks in advance
Posted
Updated 1-Jun-12 7:05am
v2

1 solution

.cshtml is a mvc 3 razor specific page. It cannot just be served like an html page. So from jquery, if your "sample" view is rendered from "Home" controller, you will have to use "/home/sample" and not just "sample.cshtml".

For example, consider the following controller:

C#
public class HomeController : Controller
{
   public ActionResult sample()
   {
       return View();
   }
}


The sample action method would return a view named "sample.cshtml" by default. So in order to get the contents of this page use /home/sample.

Hope this helps!
 
Share this answer
 
Comments
natarajangovindavel 3-Jun-12 23:24pm    
Yeah its working karthik thank you very much....

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900