VB - 将网站转换为Web应用程序

时间:2010-03-18 02:36:06

标签: vb.net

这是我第一次做VB :-)我继承了一个网站,我已经在VS2008中转换成了一个Web应用程序。转换适用于除Gallery控件之外的所有内容。

我得到的编译错误是:

类型“图库”未在文件中定义:gallery_oct07.aspx.designer.vb

Option Strict On
Option Explicit On

Partial Public Class gallery_oct07

    '''<summary>
    '''Gallery1 control.
    '''</summary>
    '''<remarks>
    '''Auto-generated field.
    '''To modify move field declaration from designer file to code-behind file.
    '''</remarks>
    Protected WithEvents Gallery1 As Global.Gallery
End Class

Global.Gallery下的波浪线。

gallery_oct07.aspx.vb是:

Partial Class gallery_oct07
    Inherits System.Web.UI.Page

End Class

以及gallery_oct07.aspx文件:

<%@ page language="VB" masterpagefile="~/MasterPage.master" autoeventwireup="false" inherits="WebApplication1.gallery_oct07" title="2007 Trip Photos" Codebehind="~/gallery_oct07.aspx.vb" %>

<%@ Register Src="Gallery.ascx" TagName="Gallery" TagPrefix="uc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<script language="javascript" type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<script language="javascript" type="text/javascript" src="js/thickbox.js"></script>
    <p class="title">
        Koru Care Christchurch Charitable Trust</p>
    <img src="images/green_space.gif" />
    <p class="title">
        Trip Photos</p>
    <p class="subTitle">
        Los Angeles 2007</p>
    <p class="text">
        Click for larger Image</p>
    <uc1:Gallery ID="Gallery1" runat="server" ImageFolder="images/oct2007/"  />    
</asp:Content>

Gallery.ascx是:

<%@ Control Language="C#" AutoEventWireup="true" Codebehind="Gallery.ascx.cs" Inherits="WebApplication1.Gallery"%>

<asp:Repeater runat="server" ID="rptGallery">
    <HeaderTemplate>
        <ul class='<%#CssClass%>'>
    </HeaderTemplate>
    <ItemTemplate>
        <li><a href='<%#ImageFolder + Eval("Name") %>' class="thickbox" rel="gallery"><img src='<%#ImageFolder + "thumb/" + Eval("Name") %>' /></a></li>
            </ItemTemplate>
    <FooterTemplate>
        </ul></FooterTemplate>
</asp:Repeater>

后面的代码是:

using System;
using System.IO;

namespace WebApplication1
{
    public partial class Gallery : System.Web.UI.UserControl
    {
        public string _ImageFolder;
        public string ImageFolder
        {
            get
            {
                return _ImageFolder;
            }
            set
            {
                _ImageFolder = value;
            }
        }

        private string _cssClass = "gallery";

        public string CssClass
        {
            get
            {
                return _cssClass;
            }
            set
            {
                _cssClass = value;
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {

            DirectoryInfo dir = new DirectoryInfo(MapPath(ImageFolder));
            FileInfo[] images = dir.GetFiles("*.jpg");

            rptGallery.DataSource = images;
            rptGallery.DataBind();

        }

        protected void Page_PreRender(object sender, EventArgs e)
        {

        }
    }
}

感觉就像命名空间问题..我的项目命名空间是WebApplication1。

干杯!

4 个答案:

答案 0 :(得分:0)

首先尝试从Global.Gallery更改为Global.WebApplication1.Gallery

答案 1 :(得分:0)

打开“对象浏览器”,将“对象浏览器设置”更改为“查看容器”,然后浏览项目的命名空间。这可以帮助您解决问题。

答案 2 :(得分:0)

替换

Protected WithEvents Gallery1 As Global.Gallery

Protected WithEvents Gallery1 As Gallery

答案 3 :(得分:0)

似乎没有找到Gallery的代码,这意味着它要么没有获得构建,要么具有不符合您期望的命名空间。

下载reflector,打开DLL,看看你是否可以确定控件的位置,名称空间。

其他要检查的事项:

  • 您的项目是否有可能改变内容的任何全局命名空间或DLL设置?
  • 你确定控件的构建操作是正确的吗? (即确保它不被忽略,或作为内容包括在内)