【发布时间】:2012-10-10 02:27:44
【问题描述】:
我有一个使用 CodeFile 的 asp 项目,但是当我将其更改为 CodeBehind 时,在 aspx 文件中无法识别 vb 函数,从而在 aspx 文件中给出“名称...未声明”错误。
为了使用 CodeBehind,除了将顶行中的 codefile 更改为 codebehind 之外,还有其他事情要做吗?
以下代码在 aspx 文件中收到错误“名称 'connex' 未声明”。
<%@ 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 时,我删除了根命名空间,但我将其保留在所有其他项目中。
标签: asp.net code-behind