Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Oct 31, 2008 03:36 PM by n26
Oct 31, 2008 08:58 AM|LINK
first sorry for my bad english, it's not my first language [;)]
public JsonResult Draw(int width, int height)
AddTask.Assign("#mapContainer > div", View("Map", Fields));
To work with Ajax I have wrote my own class. After building an object using AddTask (line 4 and 5) I want to return this object as Json (line 7).But to get this work done I need to transform the ViewResult from View("Map", Fields) (line 4) to a string. Is this possible?
Edit:Maybe a bit more understandable...I want to to something like this:
string content = View("Map");
It is obvious to me, that this doesn't works. But I really need something like this. I need the functionality to store a rendered View or PartialView in a variable... is this possible?
Oct 31, 2008 02:48 PM|LINK
Try the properties of the View("Map", Fields) ViewResult --> there's a View property (an IView) which allows you to render contents to any TextWriter. StringWriter might be a good choice to actually render the IView to a string which can be used. Good luck!
Oct 31, 2008 03:36 PM|LINK
First, thanks for your answere!
void Render(ViewContext viewContext, TextWriter writer);
I think you mean this one? Seemingly this could help... but I allready searched a way to get the current ViewContext for useing in the Controller and I couldn't found one. Did you or sombody else know a solution to do so?