I would like to get the html code that will generate the view in a string, modify it in my controller, and then add it to my JsonResult.
I found code that will do what I'm talking about from partial. I would like to do this from an aspx view though.
- Additional explanation:
Say I have a Frame.aspx page that / Controller / Frame will return
I would like to get my hand from the answer before this so that I can wrap it with jsonp. I don’t want to edit the result of returning to the code every time, so I want to programmatically download the file.
/ Controller / Frame returns the contents of Frame.aspx: <html><body>hello</body></html>
Say there is a function that displays a view in a row builder
StringBuilder sb = new StringBuilder(); RenderView(sb, "Frame");
now take sb and wrap it with jsonp:
public JsonResult Frame(string callback) { StringBuilder sb = new StringBuilder(); RenderView(sb, "Frame"); return new JsonResult { Data = "(function() { " + callback + "(" + clientResponse + "); })();" , JsonRequestBehavior = JsonRequestBehavior.AllowGet }; }
Abdo
source share