viewcontext

Get the Current ViewContext in ASP.Net MVC

I have a ASP.Net MVC JsonResult function in which I want to return the contents of a PartialView (The content has to be loaded using Ajax, and for some reason I can't return a PartialViewResult). To render the PartialView I need the ViewContext object. How do you get the current ViewContext object within an Action method? I don't even ...

Why is ViewContext.ViewName not available?

I read several examples on the web which use the following code: Private Function SomeFunction(ByVal htmlhelper As HtmlHelper) As String Dim controller As Controller = htmlhelper.ViewContext.Controller If controller IsNot Nothing Then Dim vname as String = htmlhelper.ViewContext.ViewName 'This doesnt work End If End...

ASP.NET MVC - Get ViewContext from helper method

I would like to create a static helper method that I can call from a view. Is it possible for a helper method to have access to the current ViewContext without needing to explicitly pass the ViewContext to the method as a parameter? Something like HttpContext.Current except for ViewContext. Thanks for any help. -Keith ...

ViewContext.Writer() doesn't exist in ASP.NET MVC 1.0?

I have the following code in an ASP.NET MVC 2 application. internal TextWriter _writer; // some stuff _writer = _viewContext.Writer; _writer.Write(_tag.ToString(TagRenderMode.EndTag)); I tried to move it to MVC 1 and now it doesn't build any more. I'm getting this error: 'System.Web.Mvc.ViewContext' does not contain a definition for...