Perhaps this is a question for Programmers - I'm sure someone will advise me if so.
When using MVC, I can also access the Html Helper variable and use whatever extension methods are defined, either the .Net ones or ones I might have specified myself.
@Html.Raw("<h1>This is my HTML</h1>")
How is this achieved? Say I wanted to add a separate object for another reason and have it available to all views in my MVC app?
I know I can't add it to the controller, as one view might be accessed by several controllers.
So my best guess is needing to subclass IView?
Edit: sorry - I didn't explain myself. At least I think...
I want the object to be available, but also instantiated. So for example, say I had an object called glosrob
, with a method SayHello()
and wanted to be able use it thusly:
@glosrob.SayHello()
Essentially I want to avoid having to add code to construct the object on each view e.g. avoid this
@{
var glosrob = new Glosrob();
}