1

我有一个使用 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
4

1 回答 1

1

检查你的

Inherits="_browse"

确保包含正确的命名空间。

Inherits="MyNameSpace._browse"
于 2012-10-09T18:27:44.357 回答