How to use a method from class in other namespaces at .aspx pages

You can use using statement to inculde different namespaces in you code behind file. But still you can’t call methods from classes that live in other namespaces (Different from you page class namespace) from you content pages (.aspx).

To make this work you must use import namespace directive after you page directive.

<%@ Import="" Namespace="ICF.Common" %>

This can be a hard tast if you have a lot of pages. So you can define your namespaces in you web.config file and call your business class methods in your .aspx pages whenever you want. 

<?xml version="1.0"?>
<configuration>
    <system.web>
        <pages>
            <namespaces>
                <add namespace="ICF" />
                <add namespace="ICF.Common"/>
            </namespaces>
        </pages>
    </system.web>
</configuration>

Happy coding…

Posts created 141

Leave a Reply

Related Posts

Begin typing your search term above and press enter to search. Press ESC to cancel.

Back To Top