Noob -- BC30002: Type 'Table' is not defined.

Discussion in 'ASP .Net' started by CJM, Aug 12, 2004.

  1. CJM

    CJM Guest

    I'm finally taking my first few steps with ASP.NET, and I'm just workign my
    way through some of the basics.

    As a vehicle for my learning, I'm re-writing a simple report page for on of
    my ASP applications.

    I have two tables on this page. One is where the user requests a report for
    a given ID number, the second is the table of result. Obviously I dont want
    to show the results table until the query has been submitted, so I'm trying
    to hide the table until IsPostBack = True.

    As I understand it, I must declare the page controls, e.g. my tables, before
    I can manipulate them in the CodeBehind page. I've done this but clearly I
    am missing something because I am getting this error: BC30002: Type 'Table'
    is not defined.

    Thanks in advance

    Chris

    Code Snippets:

    viewta.2aspx.vb:
    Public Class viewta2
    Inherits System.Web.UI.Page

    Protected WithEvents tblResults As Table
    Protected WithEvents tblRequest As Table


    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles MyBase.Load
    'Put user code to initialize the page here

    If IsPostBack Then
    'Hide Search button
    tblResults.Visible = True
    tblRequest.Visible = False
    Else
    'Hide(results)
    tblResults.Visible = False
    tblRequest.Visible = True
    End If

    End Sub

    End Class


    viewta2.aspx:
    <%@ Page Inherits="viewta2" src="viewta2.aspx.vb" %>
    <script runat="server">

    Sub Page_Load
    If Not IsPostBack Then
    lblTANumber.visible=false
    End If
    End Sub

    </script>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
    <html lang="en">
    <head>
    <title>viewta2</title>
    <meta name=vs_defaultClientScript content="JavaScript">
    <meta name=vs_targetSchema
    content="http://schemas.microsoft.com/intellisense/ie5">
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <link rel="stylesheet" href="TADB.css" type="text/css">
    </head>
    <body MS_POSITIONING="GridLayout">

    <form id="frmReport" method="post" runat="server">
    <table id="tblRequest" class="tbl centered" cellspacing="0"
    runat="server">
    <tr>
    <th colspan="2">View TA Details</th>
    </tr>
    <tr>
    <td>TA Number:</td>
    <td><asp:TextBox ID="txtTANumber" MaxLength="10" Runat="server"/></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td><asp:Button ID="cmdSearch" Text="Search" Runat="server"/></td>
    </tr>
    </table>
    <table id="tblResults" class="tbl centered" cellspacing="0"
    runat="server">
    <tr>
    <th>TA Number:</th>
    <th><asp:Label ID="lblTANumber" Width="10" Runat="server"/></th>
    </tr>
    <tr>
    <td>PO Number:</td>
    <td><asp:Label ID="lblPONumber" Runat="server"/></td>
    </tr>
    <tr>
    <td>PO Line:</td>
    <td><asp:Label ID="lblPOLine" Runat="server"/></td>
    </tr>
    <tr>
    <td>Part No:</td>
    <td><asp:Label ID="lblPartNo" Runat="server"/></td>
    </tr>
    <tr>
    <td>Part XRef:</td>
    <td><asp:Label ID="lblPartXRef" Runat="server"/></td>
    </tr>
    <tr>
    <td>Description:</td>
    <td><asp:Label ID="lblDescText" Runat="server"/></td>
    </tr>
    <tr>
    <td>Quantity Rec'd:</td>
    <td><asp:Label ID="lblQuantityRecd" Runat="server"/></td>
    </tr>
    <tr>
    <td>Advice Note:</td>
    <td><asp:Label ID="lblAdviceNote" Runat="server"/></td>
    </tr>
    <tr>
    <td>Supplier ID:</td>
    <td><asp:Label ID="lblSuppierID" Runat="server"/></td>
    </tr>
    <tr>
    <td>Cert/Cast No:</td>
    <td><asp:Label ID="lblCastNo" Runat="server"/></td>
    </tr>
    <tr>
    <td>Date Rec'd:</td>
    <td><asp:Label ID="lblDateRecd" Runat="server"/></td>
    </tr>
    </table>
    </form>

    </body>
    </html>
     
    CJM, Aug 12, 2004
    #1
    1. Advertising

  2. CJM

    Toby Mathews Guest

    You haven't given it enough information about the class you're creating an
    instance of. Try something like:

    Protected WithEvents tblResults As System.Web.UI.WebControls.Table

    Toby Mathews

    "CJM" <> wrote in message
    news:...
    > I'm finally taking my first few steps with ASP.NET, and I'm just workign

    my
    > way through some of the basics.
    >
    > As a vehicle for my learning, I'm re-writing a simple report page for on

    of
    > my ASP applications.
    >
    > I have two tables on this page. One is where the user requests a report

    for
    > a given ID number, the second is the table of result. Obviously I dont

    want
    > to show the results table until the query has been submitted, so I'm

    trying
    > to hide the table until IsPostBack = True.
    >
    > As I understand it, I must declare the page controls, e.g. my tables,

    before
    > I can manipulate them in the CodeBehind page. I've done this but clearly I
    > am missing something because I am getting this error: BC30002: Type

    'Table'
    > is not defined.
    >
    > Thanks in advance
    >
    > Chris
    >
    > Code Snippets:
    >
    > viewta.2aspx.vb:
    > Public Class viewta2
    > Inherits System.Web.UI.Page
    >
    > Protected WithEvents tblResults As Table
    > Protected WithEvents tblRequest As Table
    >
    >
    > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    > System.EventArgs) Handles MyBase.Load
    > 'Put user code to initialize the page here
    >
    > If IsPostBack Then
    > 'Hide Search button
    > tblResults.Visible = True
    > tblRequest.Visible = False
    > Else
    > 'Hide(results)
    > tblResults.Visible = False
    > tblRequest.Visible = True
    > End If
    >
    > End Sub
    >
    > End Class
    >
    >
    > viewta2.aspx:
    > <%@ Page Inherits="viewta2" src="viewta2.aspx.vb" %>
    > <script runat="server">
    >
    > Sub Page_Load
    > If Not IsPostBack Then
    > lblTANumber.visible=false
    > End If
    > End Sub
    >
    > </script>
    > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    > "http://www.w3.org/TR/html4/strict.dtd">
    > <html lang="en">
    > <head>
    > <title>viewta2</title>
    > <meta name=vs_defaultClientScript content="JavaScript">
    > <meta name=vs_targetSchema
    > content="http://schemas.microsoft.com/intellisense/ie5">
    > <meta http-equiv="Content-Type" content="text/html;

    charset=ISO-8859-1">
    > <link rel="stylesheet" href="TADB.css" type="text/css">
    > </head>
    > <body MS_POSITIONING="GridLayout">
    >
    > <form id="frmReport" method="post" runat="server">
    > <table id="tblRequest" class="tbl centered" cellspacing="0"
    > runat="server">
    > <tr>
    > <th colspan="2">View TA Details</th>
    > </tr>
    > <tr>
    > <td>TA Number:</td>
    > <td><asp:TextBox ID="txtTANumber" MaxLength="10" Runat="server"/></td>
    > </tr>
    > <tr>
    > <td>&nbsp;</td>
    > <td><asp:Button ID="cmdSearch" Text="Search" Runat="server"/></td>
    > </tr>
    > </table>
    > <table id="tblResults" class="tbl centered" cellspacing="0"
    > runat="server">
    > <tr>
    > <th>TA Number:</th>
    > <th><asp:Label ID="lblTANumber" Width="10" Runat="server"/></th>
    > </tr>
    > <tr>
    > <td>PO Number:</td>
    > <td><asp:Label ID="lblPONumber" Runat="server"/></td>
    > </tr>
    > <tr>
    > <td>PO Line:</td>
    > <td><asp:Label ID="lblPOLine" Runat="server"/></td>
    > </tr>
    > <tr>
    > <td>Part No:</td>
    > <td><asp:Label ID="lblPartNo" Runat="server"/></td>
    > </tr>
    > <tr>
    > <td>Part XRef:</td>
    > <td><asp:Label ID="lblPartXRef" Runat="server"/></td>
    > </tr>
    > <tr>
    > <td>Description:</td>
    > <td><asp:Label ID="lblDescText" Runat="server"/></td>
    > </tr>
    > <tr>
    > <td>Quantity Rec'd:</td>
    > <td><asp:Label ID="lblQuantityRecd" Runat="server"/></td>
    > </tr>
    > <tr>
    > <td>Advice Note:</td>
    > <td><asp:Label ID="lblAdviceNote" Runat="server"/></td>
    > </tr>
    > <tr>
    > <td>Supplier ID:</td>
    > <td><asp:Label ID="lblSuppierID" Runat="server"/></td>
    > </tr>
    > <tr>
    > <td>Cert/Cast No:</td>
    > <td><asp:Label ID="lblCastNo" Runat="server"/></td>
    > </tr>
    > <tr>
    > <td>Date Rec'd:</td>
    > <td><asp:Label ID="lblDateRecd" Runat="server"/></td>
    > </tr>
    > </table>
    > </form>
    >
    > </body>
    > </html>
    >
    >
     
    Toby Mathews, Aug 12, 2004
    #2
    1. Advertising

  3. CJM

    Toby Mathews Guest

    PS Syntax may not be exact, I'm a C# person!

    "Toby Mathews" <> wrote in message
    news:cffve9$dbf$...
    > You haven't given it enough information about the class you're creating an
    > instance of. Try something like:
    >
    > Protected WithEvents tblResults As System.Web.UI.WebControls.Table
    >
    > Toby Mathews
    >
    > "CJM" <> wrote in message
    > news:...
    > > I'm finally taking my first few steps with ASP.NET, and I'm just workign

    > my
    > > way through some of the basics.
    > >
    > > As a vehicle for my learning, I'm re-writing a simple report page for on

    > of
    > > my ASP applications.
    > >
    > > I have two tables on this page. One is where the user requests a report

    > for
    > > a given ID number, the second is the table of result. Obviously I dont

    > want
    > > to show the results table until the query has been submitted, so I'm

    > trying
    > > to hide the table until IsPostBack = True.
    > >
    > > As I understand it, I must declare the page controls, e.g. my tables,

    > before
    > > I can manipulate them in the CodeBehind page. I've done this but clearly

    I
    > > am missing something because I am getting this error: BC30002: Type

    > 'Table'
    > > is not defined.
    > >
    > > Thanks in advance
    > >
    > > Chris
    > >
    > > Code Snippets:
    > >
    > > viewta.2aspx.vb:
    > > Public Class viewta2
    > > Inherits System.Web.UI.Page
    > >
    > > Protected WithEvents tblResults As Table
    > > Protected WithEvents tblRequest As Table
    > >
    > >
    > > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    > > System.EventArgs) Handles MyBase.Load
    > > 'Put user code to initialize the page here
    > >
    > > If IsPostBack Then
    > > 'Hide Search button
    > > tblResults.Visible = True
    > > tblRequest.Visible = False
    > > Else
    > > 'Hide(results)
    > > tblResults.Visible = False
    > > tblRequest.Visible = True
    > > End If
    > >
    > > End Sub
    > >
    > > End Class
    > >
    > >
    > > viewta2.aspx:
    > > <%@ Page Inherits="viewta2" src="viewta2.aspx.vb" %>
    > > <script runat="server">
    > >
    > > Sub Page_Load
    > > If Not IsPostBack Then
    > > lblTANumber.visible=false
    > > End If
    > > End Sub
    > >
    > > </script>
    > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    > > "http://www.w3.org/TR/html4/strict.dtd">
    > > <html lang="en">
    > > <head>
    > > <title>viewta2</title>
    > > <meta name=vs_defaultClientScript content="JavaScript">
    > > <meta name=vs_targetSchema
    > > content="http://schemas.microsoft.com/intellisense/ie5">
    > > <meta http-equiv="Content-Type" content="text/html;

    > charset=ISO-8859-1">
    > > <link rel="stylesheet" href="TADB.css" type="text/css">
    > > </head>
    > > <body MS_POSITIONING="GridLayout">
    > >
    > > <form id="frmReport" method="post" runat="server">
    > > <table id="tblRequest" class="tbl centered" cellspacing="0"
    > > runat="server">
    > > <tr>
    > > <th colspan="2">View TA Details</th>
    > > </tr>
    > > <tr>
    > > <td>TA Number:</td>
    > > <td><asp:TextBox ID="txtTANumber" MaxLength="10"

    Runat="server"/></td>
    > > </tr>
    > > <tr>
    > > <td>&nbsp;</td>
    > > <td><asp:Button ID="cmdSearch" Text="Search" Runat="server"/></td>
    > > </tr>
    > > </table>
    > > <table id="tblResults" class="tbl centered" cellspacing="0"
    > > runat="server">
    > > <tr>
    > > <th>TA Number:</th>
    > > <th><asp:Label ID="lblTANumber" Width="10" Runat="server"/></th>
    > > </tr>
    > > <tr>
    > > <td>PO Number:</td>
    > > <td><asp:Label ID="lblPONumber" Runat="server"/></td>
    > > </tr>
    > > <tr>
    > > <td>PO Line:</td>
    > > <td><asp:Label ID="lblPOLine" Runat="server"/></td>
    > > </tr>
    > > <tr>
    > > <td>Part No:</td>
    > > <td><asp:Label ID="lblPartNo" Runat="server"/></td>
    > > </tr>
    > > <tr>
    > > <td>Part XRef:</td>
    > > <td><asp:Label ID="lblPartXRef" Runat="server"/></td>
    > > </tr>
    > > <tr>
    > > <td>Description:</td>
    > > <td><asp:Label ID="lblDescText" Runat="server"/></td>
    > > </tr>
    > > <tr>
    > > <td>Quantity Rec'd:</td>
    > > <td><asp:Label ID="lblQuantityRecd" Runat="server"/></td>
    > > </tr>
    > > <tr>
    > > <td>Advice Note:</td>
    > > <td><asp:Label ID="lblAdviceNote" Runat="server"/></td>
    > > </tr>
    > > <tr>
    > > <td>Supplier ID:</td>
    > > <td><asp:Label ID="lblSuppierID" Runat="server"/></td>
    > > </tr>
    > > <tr>
    > > <td>Cert/Cast No:</td>
    > > <td><asp:Label ID="lblCastNo" Runat="server"/></td>
    > > </tr>
    > > <tr>
    > > <td>Date Rec'd:</td>
    > > <td><asp:Label ID="lblDateRecd" Runat="server"/></td>
    > > </tr>
    > > </table>
    > > </form>
    > >
    > > </body>
    > > </html>
    > >
    > >

    >
    >
     
    Toby Mathews, Aug 12, 2004
    #3
  4. CJM

    CJM Guest

    Toby,

    Seem you were on the right lines...

    I'm working from example in "ASP Unleashed" where "Protected WithEvents
    lblMessage as Label" was used... I wonder is their code wrong or are they
    using some shortcut method?

    Anyway, at first I changed to System.Web.UI.WebControls.Table... but this
    meant I had to change all my <table>, <tr>, <th> and <td> tags needed to be
    changed!

    So I've opted for System.Web.UI.HtmlControls.HtmlTable - I know I'm missing
    out on functionality, but I can't imagine I'm missing that much!

    Cheers

    Chris

    [Addendum: I noticed that I can add Imports directives (eg Imports
    System.Web.UI.HtmlControls) to allow shortcut declarations (eg. Protected
    WithEvents tblResults As HtmlTable)]


    "Toby Mathews" <> wrote in message
    news:cffve9$dbf$...
    > You haven't given it enough information about the class you're creating an
    > instance of. Try something like:
    >
    > Protected WithEvents tblResults As System.Web.UI.WebControls.Table
    >
    > Toby Mathews
    >
     
    CJM, Aug 12, 2004
    #4
  5. CJM

    Toby Mathews Guest

    Chris,

    Yes, you can use Inherits to get the class to inherit everything from
    another class like this:

    Inherits System.Web.UI.WebControls

    like the line:

    Inherits System.Web.UI.Page

    you already have in your code (this inherits all the methods, classes etc of
    the Page class, making them available from within your code without having
    to type out everything from System up each time).

    Hope this helps,

    Toby

    "CJM" <> wrote in message
    news:u0b$...
    > Toby,
    >
    > Seem you were on the right lines...
    >
    > I'm working from example in "ASP Unleashed" where "Protected WithEvents
    > lblMessage as Label" was used... I wonder is their code wrong or are they
    > using some shortcut method?
    >
    > Anyway, at first I changed to System.Web.UI.WebControls.Table... but this
    > meant I had to change all my <table>, <tr>, <th> and <td> tags needed to

    be
    > changed!
    >
    > So I've opted for System.Web.UI.HtmlControls.HtmlTable - I know I'm

    missing
    > out on functionality, but I can't imagine I'm missing that much!
    >
    > Cheers
    >
    > Chris
    >
    > [Addendum: I noticed that I can add Imports directives (eg Imports
    > System.Web.UI.HtmlControls) to allow shortcut declarations (eg. Protected
    > WithEvents tblResults As HtmlTable)]
    >
    >
    > "Toby Mathews" <> wrote in message
    > news:cffve9$dbf$...
    > > You haven't given it enough information about the class you're creating

    an
    > > instance of. Try something like:
    > >
    > > Protected WithEvents tblResults As System.Web.UI.WebControls.Table
    > >
    > > Toby Mathews
    > >

    >
    >
     
    Toby Mathews, Aug 12, 2004
    #5
  6. HI Chris,

    Since the ASP.NET has two set of controls Html SErver controls and
    WEbserver controls, it's better that we declare a control as its full name.
    And generally, if you don't need to create control from the html template
    such as
    <table runat=server> ...

    Here are the related document in msdn:
    You can just use the WebControls since that also provide better
    encapsulation and flexibility.
    #Introduction to ASP.NET Server Controls
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/
    vbconintroductiontowebformscontrols.asp

    #HTML Server Controls
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/ht
    ml/cpconASPSyntaxForHTMLControls.asp

    Hope also helps. thanks.

    Regards,

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)

    Get Preview at ASP.NET whidbey
    http://msdn.microsoft.com/asp.net/whidbey/default.aspx
     
    Steven Cheng[MSFT], Aug 13, 2004
    #6
  7. CJM

    CJM Guest

    I thought I'd reade somewhere that certain classes were automatically
    inherited, but it appears not.

    But it working fine now... well I'm on to my next problem actually, but I
    can successfully manipulate the page controls from the form-behind page now,
    thanks.

    I would say, that for simple pages, there seem to be an awful lot of work to
    do in comparison with ASP/PHP. I know that ultimately .NET is more powerful,
    but for the simple stuff, there seems to be a lot of work to do...
    Importing, inheriting, declaring form controls etc, etc...

    Thanks anyway

    Chris

    "Steven Cheng[MSFT]" <> wrote in message
    news:...
    > HI Chris,
    >
    > Since the ASP.NET has two set of controls Html SErver controls and
    > WEbserver controls, it's better that we declare a control as its full

    name.
    > And generally, if you don't need to create control from the html template
    > such as
    > <table runat=server> ...
    >
    > Here are the related document in msdn:
    > You can just use the WebControls since that also provide better
    > encapsulation and flexibility.
    > #Introduction to ASP.NET Server Controls
    >

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/
    > vbconintroductiontowebformscontrols.asp
    >
    > #HTML Server Controls
    >

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/ht
    > ml/cpconASPSyntaxForHTMLControls.asp
    >
     
    CJM, Aug 13, 2004
    #7
  8. Hi Chris,


    Thanks for the followup. As for the ASP.NET web page, if the page is not
    very complex, we can just use a aspx page which has functions inline rather
    than provide a codebehind model. Here are some reference on this:

    #Should I use Code-behind or Code-Inside (or Code-beside)?
    http://msdn.microsoft.com/asp.net/community/inbox/codebeside/default.aspx

    #Web Forms Code Model
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/
    vbconwebformscodemodel.asp

    Thanks.

    Regards,

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)

    Get Preview at ASP.NET whidbey
    http://msdn.microsoft.com/asp.net/whidbey/default.aspx
     
    Steven Cheng[MSFT], Aug 13, 2004
    #8
    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. Nuve
    Replies:
    0
    Views:
    2,016
  2. Nuve Nai
    Replies:
    0
    Views:
    895
    Nuve Nai
    Oct 23, 2003
  3. David Lozzi

    BC30002: Type 'EventArgs' is not defined

    David Lozzi, Dec 6, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    2,943
    David Lozzi
    Dec 6, 2004
  4. Mel
    Replies:
    8
    Views:
    5,929
    Mark Rae [MVP]
    Aug 10, 2007
  5. Niks

    BC30002: Type 'DataRowView' is not defined.

    Niks, Apr 14, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    203
Loading...

Share This Page