I've added the following namespace to my Views web.config file:
<add namespace="System.Web.Mvc.Html5" />
Now the issue is that in the Views, I can only use the types using the fullname:
@System.Web.Mvc.Html5.InputTypes.Html5TextBox()
I'd like to be able to do:
@InputTypes.Html5TextBox()
How can I do that ?
Make sure you have added this namespace to the ~/Views/web.config
file and not to the standard ~/web.config
file:
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Optimization"/>
<add namespace="System.Web.Routing" />
<add namespace="System.Web.Mvc.Html5" />
</namespaces>
</pages>
</system.web.webPages.razor>
Also make sure that after adding this namespace you have closed and reopened your Razor view in Visual Studio for the changes to have taken effect.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With