Problem referencing usercontrol in page codebehind?

Discussion in 'ASP .Net' started by N. Demos, Jun 19, 2005.

  1. N. Demos

    N. Demos Guest

    Hello,
    I have a custom usercontrol, of which I have two instances of in my aspx
    page. Both the usercontrol and page have codebehind. In the page
    codebehind, I want a member variable for each usercontrol. My problem is
    that I keep getting a compiler error on the usercontrol variables in my
    page codebehind (BC30002: Type 'CityGeoPosSelectClass' is not defined.)
    For whatever reason, my usercontrol class is not being declared in the
    page codebehind file. I've read every article I could find on this and I
    still can't seem to get this to work. I would greatly appreciate if
    someone would take a look at this and give me some pointers on what I'm
    doing wrong here (relevant code below).

    I'm not using Visual Studio .NET to develop this, and my version of the
    ..NET framework is 1.1.4322.573 with IIS 5.1. Thanks for your time and
    attention.

    Regards,
    N. Demos


    ERROR MESSAGE:
    ---------------
    Compiler Error Message: BC30002: Type 'CityGeoPosSelectClass' is not
    defined.

    Source Error:
    Line 11: Public Class CityGeoTestCodebehind : Inherits Page
    Line 12: Public dRadiusEarth As Double
    Line 13: Public ucCityListBox1 As CityGeoPosSelectClass
    Line 14: Public ucCityListBox2 As CityGeoPosSelectClass
    Line 15:

    Source File: C:\BegASPNET\ch16\CityGeoPosTest.vb Line: 13


    CODE:
    -----------

    '********** CityGeoPosSelect.ascx **********
    <%@ Control inherits="CityGeoPosSelectClass" debug="true"
    src="CityGeoPosSelect.vb" classname="CityGeoPosListBox" %>

    <ASP:listbox id="lstbxCities" autoPostBack="True"
    onSelectedIndexChanged="ShowValue" rows="20" runat="server" />
    <br /><br />
    <span>Latitude: </span>
    <ASP:textbox id="tbxLatCoord" rows="1" runat="server" />
    <br />

    <span>Longitude: </span>
    <ASP:textbox id="tbxLongCoord" rows="1" runat="server" />
    <br />

    <ASP:label id="lblCGPLBMon" runat="server" />


    '********** CityGeoPosSelect.vb **********
    Option Explicit
    Option Strict

    Imports System
    Imports System.Collections
    Imports System.Web.UI
    Imports System.Web.UI.WebControls
    Imports System.Data
    Imports System.IO
    Imports System.XML


    Public Class CityGeoPosSelectClass : Inherits UserControl

    Public lstbxCities As ListBox
    Public lblCGPLBMon As Label
    Public tbxLatCoord As TextBox
    Public tbxLongCoord As TextBox

    ' Member Functions and Subs ...
    End Class


    '********** CityGeoPosTest.aspx **********
    <%@ PAGE language="VB" debug="true" src="CityGeoPosTest.vb"
    inherits="CityGeoTestCodebehind" %>
    <%@ Register TagPrefix="UserControl" TagName="CityGeoPosListBox"
    Src="CityGeoPosSelect.ascx" %>

    <html>
    <head>
    </head>
    <body>
    <form method="post" runat="server">

    <UserControl:CityGeoPosListBox id="ucCityListBox1" runat="server" />

    <UserControl:CityGeoPosListBox id="ucCityListBox2" runat="server" />
    <br />

    ' Textbox and Submit Button ...
    </form>
    </body>
    </html>


    '********** CityGeoPosTest.vb **********
    Option Explicit
    Option Strict

    Imports System
    Imports System.Collections
    Imports System.Web.UI
    Imports System.Web.UI.WebControls


    Public Class CityGeoTestCodebehind : Inherits Page
    Public dRadiusEarth As Double

    '!!! Error Occurs Here !!!
    Public ucCityListBox1 As CityGeoPosSelectClass
    Public ucCityListBox2 As CityGeoPosSelectClass

    Public tblDistMiles As TextBox


    ' Member Functions and Subs (Page_Load() etc ...)
    End Class




    --
    Change "seven" to a digit to email me.
    N. Demos, Jun 19, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?QWxleCBNYWdoZW4=?=

    Finding/Referencing a UserControl on a Page or MasterPage

    =?Utf-8?B?QWxleCBNYWdoZW4=?=, Jul 4, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    478
    Steven Cheng[MSFT]
    Jul 7, 2006
  2. matt
    Replies:
    1
    Views:
    930
    Flinky Wisty Pomm
    Oct 31, 2006
  3. Benton
    Replies:
    10
    Views:
    702
    kferron
    Dec 5, 2006
  4. SMH
    Replies:
    0
    Views:
    600
  5. jdn
    Replies:
    3
    Views:
    189
Loading...

Share This Page