-1

enter image description here

I need to generate HTML(cshtml) page when I call asp.net controller by Ajax, and after generated page, I want to update a Iframe src to the generated page.

but I couldn't find how to generate the cshtml page dynamically.

anybody know please advice me.

Thank You!

[EDIT]

I can not call the generatePage in IFrame because I need to pass too many parameters to the controller. so I need to use POST method. so I thought I need to generate the page first using Ajax POST call and load the page in IFrame.

3
  • take a look to my answer that's something similar stackoverflow.com/questions/8992721/… Commented Jul 3, 2012 at 14:00
  • Do you mean you want to compose a .cshtml on-the-fly and then call it? Why not just build the HTML in code in the first place? Commented Jul 3, 2012 at 14:04
  • better yet, why not just return a view and have your view build out your html as you need it? Similar to Rohan below, but customize the created html view to work with whatever parameters. Im gathering you are new to MVC, so I'll avoid discussion of ViewModels and packaging all data for your view here, but don't forget the V in MVC here. Commented Jul 3, 2012 at 14:34

2 Answers 2

1

Well sorry if I misunderstood a question, but if you need to load a View(that already exists) using Ajax and insert it into the page check this out:

Render partial view to string Renders partial view on server to html string, useful when you need to add partial view to ASP.NET MVC page via AJAX.

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

Comments

0

I't seems to me like this is your issue, but excuse me if i completely missed the point.

Right click on View, and say add view.

public ViewResult Index()
{
   return View();
}

Also, if you right click in your solution explorer on the controller folder and say add controller, you get a few options. These templates can be overridden, but that's a story for another day :P

Comments

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.