【发布时间】:2014-02-04 23:29:23
【问题描述】:
我有一个使用 All In One 样式(页面中带有 HTML 的 VB)构建的网页,我被要求将它们分开。
Default.aspx 是这样开始的:
<%@ Import Namespace="System.Net" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Configuration" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Globalization" %>
<%@ Import Namespace="System.Security" %>
<html>
<head>
<title>View an Activity (AFE)</title>
<script language="VB" runat="server">
Private m_url1, m_url2, m_downloadText, txtSupplementPage, txtExcerpt, SearchLocation, SearchLocation2, SearchLocation3, SearchLocationOrig As String
Private myTotal1, myTotal2 As Double
Private m_credentials As CredentialCache
' Start the initial page
Protected Sub Page_Load(sender As Object, e As EventArgs)
m_credentials = New CredentialCache()
If Not IsPostBack Then
继续。这只是为了向您展示我在做什么。
我创建了一个名为 Default2.aspx 的新的类似文件,其中包含 Page 指令、指定 CodeBehind 文件和命名空间(继承)。然后我把VB代码拿出来了:
<%@ Page Language="vb" AutoEventWireup="true" CodeBehind="Default.aspx.vb" Inherits="app2._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>View an Activity (AFE)</title>
由于 Default.aspx 没有使用代码隐藏文件,我将新的代码隐藏文件命名为 Default.aspx.vb。
我在此代码隐藏文件中创建了一个带有命名空间 app2 的新 _Default,并将所有 VB 从 Default.aspx 复制到它:
Namespace app2
Public Class _Default
Inherits System.Web.UI.Page
Inherits System.Net
Inherits System.IO
Inherits System.Configuration
Inherits System.Data
Inherits System.Data.OleDb
Inherits System.Data.SqlClient
Inherits System.Globalization
Inherits System.Security
Private m_url1, m_url2, m_downloadText, txtSupplementPage, txtExcerpt, SearchLocation, SearchLocation2, SearchLocation3, SearchLocationOrig As String
Private myTotal1, myTotal2 As Double
Private m_credentials As CredentialCache
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
m_credentials = New CredentialCache()
If Not IsPostBack Then
我试图提供足够多的代码,让每个人都能看到起点和我现在的位置。
我将两个新文件上传到网络服务器,然后浏览它们以查看它们的外观。
但是,现在当我尝试在浏览器中显示 Default2.aspx 时,我得到了这个 Parser Error:
解析器错误消息:无法加载类型“app2._Default”。
来源错误:
第 1 行:
第 2 行:
第 3 行:
我搞砸了什么?
【问题讨论】: