I try to create an html helper with a control from Telerik but to do that, I must have this directive at the top of the file:
@using Telerik.Web.Mvc.UI
The problem is in html helper, when I type '@using' and then try to typed 'Telerik', visual studio tells me that the namespace don't exist even if I already use this directive in many other places in the same project.
As you can see with the words in red, Telerik namespace produce errors; 'Cannot resolve symbol ...
This is the same code in one of my EditorTemplates folder of the same project but in this case, without errors:
Is it because it's not possible to have control other than the MVC framework or I missed something?
Thank you.
EDIT:
After searching and with the help of Darin, I finally found the problem. You can look in the comments of Darin answer.
Also, this this my final code that works:
@using System.Web.Mvc
@using Telerik.Web.Mvc.UI
@helper IntegerTextBox(System.Web.Mvc.HtmlHelper html, string id, int? value, bool enable = true)
{
@(html.Telerik().IntegerTextBox()
.Name(id)
.InputHtmlAttributes(new {style = "width:200px"})
.Spinners(false)
.EmptyMessage("")
.MaxValue(int.MinValue)
.MaxValue(int.MaxValue)
.Value(value)
.Enable(enable)
)
}
Like I said, you cannot use a @using directive to System.Web.Mvc to reduce the fully qualified type of the first parameter. I don't know why... 'HtmlHelper' looks like 'html helper' or '@helper' ... the word is in conflict with something in the framework of MVC? I don't know!? :(