I have an ASP.NET website written in VB.NET and trying to add MVC to it.
I managed to add controllers (to CS_Code folder) and make them running. However, I have to use some code from aspnet pages.
When I try to call method from page I ma having compile time error
public CustomerFrontend.DefaultForm DefaultForm { get; set; }
Error:
The type or namespace name 'DefaultForm' could not be found (are you missing a using directive or an assembly reference?)
Page directive definition which proves than namespace is correct:
<%@ Page Language开发者_开发技巧="vb" ValidateRequest="false"
EnableViewState="False"
AutoEventWireup="false"
Inherits="CustomerFrontend.DefaultForm"
CodeFile="DefaultForm.aspx.vb" %>
Regardless the fact if I refer to fill name or short name.
Any ideas?
Try something like this instead:
DefaultForm page = HttpContext.Current.Handler as DefaultForm;
if (page != null)
{
page.MyMethod();
}
Is "CustomerFrontend" the namespace of your application? Make sure you put the fully qualified path to the "DefaultForm" class.
精彩评论