tags:

views:

194

answers:

4

Hi

This is my first time doing VB :-) I've inherited a web site, which I've converted into a web application in VS2008. The conversion has worked for everything except a Gallery control.

The compile error I'm getting is:

Type 'Gallery' is not defined in file: 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

with squiggly lines under Global.Gallery.

The gallery_oct07.aspx.vb is:

Partial Class gallery_oct07
    Inherits System.Web.UI.Page

End Class

And the gallery_oct07.aspx file:

<%@ 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 is:

<%@ 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>

and the code behind is:

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)
        {

        }
    }
}

The feels like a namespace issue.. My project namespace is WebApplication1.

Cheers!

A: 

Try first to simply change from Global.Gallery to Global.WebApplication1.Gallery.

Paulo Santos
Thanks.. but no joy... compile error is now: Type 'Webapplication1.Gallery' is not defined
Dave
Can you post the first lines of `gallery_oct07.aspx`? because I think it might be lacking some `<%@ Register ... %>` directive.
Paulo Santos
Much appreciated Paulo for helping.. this feels like a very simple issue!!! I've posted the gallery_oct07.aspx code at the near the top of the question
Dave
A: 

Open the "Object Browser", and change the "Object Browser Settings" to "View Containers", then browse your project's namespaces. This should help you resolve the problem.

AMissico
A: 

Replace

Protected WithEvents Gallery1 As Global.Gallery

With

Protected WithEvents Gallery1 As Gallery
Vikram
A: 

It seems like the code for the Gallery isn't being found, which means it's either not getting build, or has a namespace that isn't what you're expecting.

Download reflector, open up the DLL, and see if you can figure out where the control lives, namespace wise.

Other things to check:

  • does your project have any global namespace or DLL settings that might change things?
  • are you sure the build action for the control is the correct one? (i.e. make sure it's not being ignored, or included as content)
chris
many thanks.. your answer led me to the sln. i deleted the .designer files and changed to CodeFile.. will post a sln later. thks to all. broke collar bone 2 days ago mountain bikin. 1 haded typing tough :-)
Dave