CodeFile에서 잘 작동하는 asp 프로젝트가 있지만 CodeBehind로 변경하면 vb 함수가 aspx 파일에서 인식되어 "Name ... aspx 파일에서 "오류가 선언되지 않았습니다.CodeFile OK, CodeBehind는 "not declared"오류를 나타냅니다.
CodeBehind를 사용하려면 맨 위 줄에 codefile
에서 codebehind
으로 변경하는 것 외에 다른 작업이 필요합니까?
다음 코드는 aspx 파일에서 "Name 'connex'is not declared"오류를 가져옵니다.
<%@ 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으로 작업 할 때 루트 네임 스페이스를 제거하지만 다른 모든 프로젝트에서는 그대로 두었습니다. –