asp.net page not seeing custom control, can't set properties

Discussion in 'ASP .Net Web Controls' started by Mad Scientist Jr, Feb 17, 2004.

  1. I have a asp.net.vb page with a custom control, and for some reason
    the codebehind is not seeing the control.



    The control is in a file "page_footer.ascx" in the root of the site
    and contains the following:

    <%@ Control Language="vb" AutoEventWireup="false"
    Codebehind="page_footer.ascx.vb" Inherits="mysite1.page_footer"
    TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
    <script language="VB" runat="server">
    Public sFooterText As String = ""
    </script>
    <table border="0" width="100%" cellSpacing="0" cellPadding="0">
    <tr>
    <td align="right"><font
    class="copy"><%=sFooterText%></font>&nbsp;&nbsp;&nbsp;</td>
    </tr>
    </table>



    The control is defined in my ASPX page (also in the root of the site)
    at the top of the HTML as:

    <%@ Register TagPrefix="site1" TagName="page_footer"
    Src="page_footer.ascx" %>




    An instance is defined in the HTML body as:

    <site1:page_footer id="page_footer_1" runat="server"
    sFooterText="Copyright 2004"></site1:page_footer><br>



    In the codebehind I try this:

    page_footer_1.sFooterText = "Copyright 2003"
    ^^^^^^^^^^^^^

    but "page_footer_1" is underlined in blue and I get the error 'Name
    "page_footer_1" is not declared.'



    What am I doing wrong?
     
    Mad Scientist Jr, Feb 17, 2004
    #1
    1. Advertising

  2. declare your control in your codebehind class first, just like you would do
    with any asp.net control. Otherwise it is undefined ;P

    public page_footer_1 as page_footer

    page_footer_1.sFooterText = "Copyright 2003"

    "Mad Scientist Jr" <> wrote in message
    news:...
    > I have a asp.net.vb page with a custom control, and for some reason
    > the codebehind is not seeing the control.
    >
    >
    >
    > The control is in a file "page_footer.ascx" in the root of the site
    > and contains the following:
    >
    > <%@ Control Language="vb" AutoEventWireup="false"
    > Codebehind="page_footer.ascx.vb" Inherits="mysite1.page_footer"
    > TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
    > <script language="VB" runat="server">
    > Public sFooterText As String = ""
    > </script>
    > <table border="0" width="100%" cellSpacing="0" cellPadding="0">
    > <tr>
    > <td align="right"><font
    > class="copy"><%=sFooterText%></font>&nbsp;&nbsp;&nbsp;</td>
    > </tr>
    > </table>
    >
    >
    >
    > The control is defined in my ASPX page (also in the root of the site)
    > at the top of the HTML as:
    >
    > <%@ Register TagPrefix="site1" TagName="page_footer"
    > Src="page_footer.ascx" %>
    >
    >
    >
    >
    > An instance is defined in the HTML body as:
    >
    > <site1:page_footer id="page_footer_1" runat="server"
    > sFooterText="Copyright 2004"></site1:page_footer><br>
    >
    >
    >
    > In the codebehind I try this:
    >
    > page_footer_1.sFooterText = "Copyright 2003"
    > ^^^^^^^^^^^^^
    >
    > but "page_footer_1" is underlined in blue and I get the error 'Name
    > "page_footer_1" is not declared.'
    >
    >
    >
    > What am I doing wrong?
     
    Alessandro Zifiglio, Feb 19, 2004
    #2
    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. Nathan Sokalski
    Replies:
    0
    Views:
    946
    Nathan Sokalski
    Oct 17, 2005
  2. Mad Scientist Jr

    asp.net page not seeing custom control, can't set properties

    Mad Scientist Jr, Feb 17, 2004, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    210
    Mad Scientist Jr
    Feb 17, 2004
  3. Nathan Sokalski
    Replies:
    0
    Views:
    223
    Nathan Sokalski
    Oct 17, 2005
  4. NKaufman

    Set Page properties in custom control

    NKaufman, Jul 22, 2008, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    899
    Peter Bucher [MVP]
    Aug 20, 2008
  5. Nathan Sokalski
    Replies:
    0
    Views:
    245
    Nathan Sokalski
    Oct 17, 2005
Loading...

Share This Page