Rita
Rita

Reputation: 735

The name html doesn't exist in the current context on MVC View Page

HI I have a view that is created from the Controllder Method.

Now I am writing the HTML View Code on this Page.

Somehow I am not getting any html controls on this page. When i type the below line, it says "The name html doesn't exist in the current context" Ex: <%= Html.TextBox

Any Clue why i am not getting html tags.

Appreciate your response.

Upvotes: 1

Views: 1908

Answers (1)

Robert Harvey
Robert Harvey

Reputation: 180918

Are you missing your Inherits attribute in your Page declaration at the top of the view?

It should look like this (if it is strongly-typed):

Inherits="System.Web.Mvc.ViewPage<MyNamespace.Models.MyViewModel>"

or like this (if it is not strongly-typed):

Inherits="System.Web.Mvc.ViewPage"

I find that if I remove this declaration from my view, the Html object will no longer intellisense.

Upvotes: 1

Related Questions