Questions tagged [viewcontext]
25 questions
13
votes
1 answer
What's the purpose of having a ViewContext property on a Tag Helper?
I have 2 questions:
1. what is Viewcontext and what are its advantages?
2. why we have to use it in tag helpers?
Actually i am the beginner and follow the "Pro ASP.NET Core MVC,6th Edition" by adam freeman in this he make a taghelper class in…

Ahmad Qasim
- 452
- 1
- 8
- 26
5
votes
1 answer
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…

Keith
- 2,618
- 4
- 29
- 44
4
votes
1 answer
Specify stylesheet media when rendering view with MVC ViewContext
In my razor views, I have:
Which correctly applies that stylesheet when printing the page.
However, in some cases I'm rendering the view to an HTML string using…

DaveD
- 2,196
- 1
- 23
- 33
3
votes
2 answers
I'm trying to implement `link_to` in a flash message for an update action in a controller in Rails but I cannot get it to render to the browser
I have a controller like this in my project:
class BriefcasesController < ApplicationController
...
def update
@super_power = SuperPower.find(params[:super_power_id])
@briefcase.contents.delete(params[:super_power_id].to_s)
…

Victoria Vasys
- 33
- 4
3
votes
2 answers
Using ActionView::TestCase::Behavior and the view method in a presenter spec
Using the Railscast example, I have written a spec for my presenter which includes ActionView::TestCase::Behavior and passes in the view method to the presenter.
spec/spec_helper.rb:
...
config.include ActionView::TestCase::Behavior,…

Shevaun
- 1,208
- 12
- 19
2
votes
0 answers
Coredata fetch request result doubles up after every request
I'm using core data to store my master data and update it based on user interaction view UI related to same.
First, I'm fetching some data in SignupStepperVC using following method and pass it to SignupGroupVC which is embed in UIContainerView…

Mayur Karmur
- 2,119
- 14
- 35
2
votes
1 answer
Core Data's NSPersistentContainer in iOS 10 / macOS Sierra
So I am really excited to use Core Data now because of how much simpler they made it (as of WWDC 2016).
On app launch, I plan to load pre-updated data from Core Data and then have the persistentContainer's performBackgroundTask do updates/saves to…

nextseto
- 21
- 2
2
votes
1 answer
Accessing Route Data from Tag Helper in ASP.NET 5 RC1
I have been using the solution below with beta 5, but this no longer works in RC1 :
How to access RouteData from an ASP.Net 5 Tag Helper in MVC 6
ViewContext is null when it gets hit. Do I need to instantiate the ViewContext somewhere eg in…

user517406
- 13,623
- 29
- 80
- 120
2
votes
1 answer
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.…

DaveDev
- 41,155
- 72
- 223
- 385
2
votes
2 answers
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…

Cyril Gupta
- 13,505
- 11
- 64
- 87
1
vote
1 answer
MVC 3 - View rendered on top of the layout page
I am having a problem rendering my view in the layout page using mvc 3.
When I render the result using a html helper, my output is on top of everything on the page, but I have used the following
HtmlHelper.ViewContext.HttpContext.Response
I…

mc.parsa
- 56
- 1
- 6
1
vote
2 answers
How do you gain access to the helper methods inside the controller with Rails
I want to use a method i have in my helper inside my controller.
I don't know how to use the view_context which i've heard could do the trick

Vasseurth
- 6,354
- 12
- 53
- 81
1
vote
1 answer
How to use ViewContext?
I have layout page in asp.net MVC application and this page contains a navbar

Waqar Ul Khaf
- 569
- 1
- 3
- 15
1
vote
1 answer
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
…

Ropstah
- 17,538
- 24
- 120
- 194
1
vote
1 answer
Why ViewContext after RenderAction PartialView is changed? Route is lost
I'm trying to implement dynamic navigation inside of web project using MVC4. All of my dynamic parts of project are displayed as partial views rendered from controller. Now I have the situation where the initial page ViewContext is not available for…

Roman
- 665
- 1
- 9
- 24