I place using namespace in a view code behind but i can't call any class of this name space in aspx.
In codebehind:
using MVCTest.Controller;
There are two ways to add namespaces: Put @using namespace at the top of the page. Put all the namespaces in Views\Web. config.
Mvc namespace contains classes and interfaces that support the ASP.NET Model View Controller (MVC) framework for creating Web applications. This namespace includes classes that represent controllers, controller factories, action results, views, partial view, model binders, and much more. The System. Web.
The namespace for Razor Engine is System.
try to use in your aspx / ascx file
<%@ import namespace='your namespace' %>
you could also try to import your namespace in the web.config
<system.web>
<pages>
<namespaces>
<add namespace='you namespace' />
</namespaces>
</pages>
</system.web>
Add the import statement If you are using the ASP.NET (C#) engine:
<%@ Import Namespace="My.Namespace.Path" %>
<html goes here>
...
</html>
OR
Add the using statement to your view if you are using the Razor engine:
@using My.Namespace.Path
@{
ViewBag.Title = "My Page";
...
}
<html goes here>
...
</html goes here>
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