1
我有一个可以与CodeFile正常工作的asp项目,但是当我将其更改为CodeBehind时,vb函数无法在aspx文件中识别,并给出“Name ...未在aspx文件中声明“错误。CodeFile好了,CodeBehind给出了“未声明”的错误
为了使用CodeBehind,除了在顶行中将codefile
更改为codebehind
之外,还有其他一些应该完成的内容吗?
以下代码在aspx文件中获取错误“名称”连接未被声明“。
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="browse.aspx.vb" Inherits="_browse" %> <!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head runat="server"> <title>Test</title> </head>
<body>
<form id="form1" runat="server">
<div>
<%
Dim s As String = connex()
Response.Write(s)
%>
</div>
</form>
</body>
</html>
==================
Imports System
Imports System.Web
Partial Public Class _browse
Inherits System.Web.UI.Page
Function connex() As String
Return "OK"
End Function
End Class
我相信当你的应用程序有一个根名称空间,你可以在项目属性中找到'inherits =“MyNameSpace._browse”'是必需的。我相信根名称空间默认为您的应用程序的原始名称。如果没有根名称空间,'Inherits =“_ browse”'可能会起作用。在使用DNN时,我删除了根名称空间,但是我将其留在所有其他项目中。 –