class is not visible

Discussion in 'ASP .Net Building Controls' started by Lubomir, Jan 5, 2005.

  1. Lubomir

    Lubomir Guest

    Hi,

    I want to use a user control on my page. I want to reference to the control
    class from the page’s code-behind.

    I registered the control:

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

    The control is used in HTML code:
    <uc1:ButtonList id="ButtonList" runat="server"></uc1:ButtonList>

    In code-behind I access the control’s class:

    public ButtonList initialStrip;

    However, I get compiler error, namespace name “ButtonList†could not be found.


    I am using the following directives in control’s aspx file:
    <%@ Control Language="C#" Inherits="ButtonListCtrl.ButtonList"
    Codebehind="ButtonList.ascx"%>

    Control’s code-behind is:
    namespace ButtonListCtrl
    {
    public class ButtonList : System.Web.UI.UserControl
    {
    …
    }
    }

    What is needed to do to make this class visible from code-behind of the
    container page?

    Thank you for help.
    Lubomir
     
    Lubomir, Jan 5, 2005
    #1
    1. Advertising

  2. "Lubomir" <> wrote in message
    news:...
    > Hi,
    >
    > I want to use a user control on my page. I want to reference to the
    > control
    > class from the page's code-behind.
    >
    > I registered the control:
    >
    > <%@ Register TagPrefix="uc1" TagName="ButtonList" Src="ButtonList.ascx" %>
    >
    > The control is used in HTML code:
    > <uc1:ButtonList id="ButtonList" runat="server"></uc1:ButtonList>
    >
    > In code-behind I access the control's class:
    >
    > public ButtonList initialStrip;
    >
    > However, I get compiler error, namespace name "ButtonList" could not be
    > found.
    >
    >
    > I am using the following directives in control's aspx file:
    > <%@ Control Language="C#" Inherits="ButtonListCtrl.ButtonList"
    > Codebehind="ButtonList.ascx"%>
    >
    > Control's code-behind is:
    > namespace ButtonListCtrl
    > {
    > public class ButtonList : System.Web.UI.UserControl
    > {
    > .
    > }
    > }
    >
    > What is needed to do to make this class visible from code-behind of the
    > container page?


    Reference it as Button:ListCtrl.ButtonList.

    John Saunders
     
    John Saunders, Jan 6, 2005
    #2
    1. Advertising

  3. Lubomir

    Lubomir Guest

    "John Saunders" wrote:

    > "Lubomir" <> wrote in message
    > news:...
    > > Hi,
    > >
    > > I want to use a user control on my page. I want to reference to the
    > > control
    > > class from the page's code-behind.
    > >
    > > I registered the control:
    > >
    > > <%@ Register TagPrefix="uc1" TagName="ButtonList" Src="ButtonList.ascx" %>
    > >
    > > The control is used in HTML code:
    > > <uc1:ButtonList id="ButtonList" runat="server"></uc1:ButtonList>
    > >
    > > In code-behind I access the control's class:
    > >
    > > public ButtonList initialStrip;
    > >
    > > However, I get compiler error, namespace name "ButtonList" could not be
    > > found.
    > >
    > >
    > > I am using the following directives in control's aspx file:
    > > <%@ Control Language="C#" Inherits="ButtonListCtrl.ButtonList"
    > > Codebehind="ButtonList.ascx"%>
    > >
    > > Control's code-behind is:
    > > namespace ButtonListCtrl
    > > {
    > > public class ButtonList : System.Web.UI.UserControl
    > > {
    > > .
    > > }
    > > }
    > >
    > > What is needed to do to make this class visible from code-behind of the
    > > container page?

    >
    > Reference it as Button:ListCtrl.ButtonList.
    >
    > John Saunders


    It didn't help. I get an error: Invalid token ":"
     
    Lubomir, Jan 6, 2005
    #3
  4. "Lubomir" <> wrote in message
    news:...
    > "John Saunders" wrote:
    >
    >> "Lubomir" <> wrote in message
    >> news:...
    >> > Hi,
    >> >
    >> > I want to use a user control on my page. I want to reference to the
    >> > control
    >> > class from the page's code-behind.
    >> >
    >> > I registered the control:
    >> >
    >> > <%@ Register TagPrefix="uc1" TagName="ButtonList" Src="ButtonList.ascx"
    >> > %>
    >> >
    >> > The control is used in HTML code:
    >> > <uc1:ButtonList id="ButtonList" runat="server"></uc1:ButtonList>
    >> >
    >> > In code-behind I access the control's class:
    >> >
    >> > public ButtonList initialStrip;
    >> >
    >> > However, I get compiler error, namespace name "ButtonList" could not be
    >> > found.
    >> >
    >> >
    >> > I am using the following directives in control's aspx file:
    >> > <%@ Control Language="C#" Inherits="ButtonListCtrl.ButtonList"
    >> > Codebehind="ButtonList.ascx"%>
    >> >
    >> > Control's code-behind is:
    >> > namespace ButtonListCtrl
    >> > {
    >> > public class ButtonList : System.Web.UI.UserControl
    >> > {
    >> > .
    >> > }
    >> > }
    >> >
    >> > What is needed to do to make this class visible from code-behind of the
    >> > container page?

    >>
    >> Reference it as Button:ListCtrl.ButtonList.
    >>
    >> John Saunders

    >
    > It didn't help. I get an error: Invalid token ":"


    I meant:

    public ButtonListCtrl.ButtonList initialStrip;

    The colon was a typo.

    John Saunders
     
    John Saunders, Jan 6, 2005
    #4
  5. Lubmomir,
    you can only reference your control in the ButtonListCtrl.ButtonList
    format if the ButtonListCtrl is in a known assembly (ie, your control is
    compiled into an assembly it can reference). if your control is simply a
    webcontrol (.ascx) file, you cannot reference its custom properties in a
    code behind...unless the control inherits from a common interface that
    resides in an assembly. ex:

    public class ButtonListCtrl : WebControl, IButtonList {
    ...
    }

    otherwise, you will only be able to reference your control as a
    WebControl...

    Mike



    "John Saunders" <johnwsaundersiii at hotmail.com> wrote in message
    news:%...
    > "Lubomir" <> wrote in message
    > news:...
    > > "John Saunders" wrote:
    > >
    > >> "Lubomir" <> wrote in message
    > >> news:...
    > >> > Hi,
    > >> >
    > >> > I want to use a user control on my page. I want to reference to the
    > >> > control
    > >> > class from the page's code-behind.
    > >> >
    > >> > I registered the control:
    > >> >
    > >> > <%@ Register TagPrefix="uc1" TagName="ButtonList"

    Src="ButtonList.ascx"
    > >> > %>
    > >> >
    > >> > The control is used in HTML code:
    > >> > <uc1:ButtonList id="ButtonList" runat="server"></uc1:ButtonList>
    > >> >
    > >> > In code-behind I access the control's class:
    > >> >
    > >> > public ButtonList initialStrip;
    > >> >
    > >> > However, I get compiler error, namespace name "ButtonList" could not

    be
    > >> > found.
    > >> >
    > >> >
    > >> > I am using the following directives in control's aspx file:
    > >> > <%@ Control Language="C#" Inherits="ButtonListCtrl.ButtonList"
    > >> > Codebehind="ButtonList.ascx"%>
    > >> >
    > >> > Control's code-behind is:
    > >> > namespace ButtonListCtrl
    > >> > {
    > >> > public class ButtonList : System.Web.UI.UserControl
    > >> > {
    > >> > .
    > >> > }
    > >> > }
    > >> >
    > >> > What is needed to do to make this class visible from code-behind of

    the
    > >> > container page?
    > >>
    > >> Reference it as Button:ListCtrl.ButtonList.
    > >>
    > >> John Saunders

    > >
    > > It didn't help. I get an error: Invalid token ":"

    >
    > I meant:
    >
    > public ButtonListCtrl.ButtonList initialStrip;
    >
    > The colon was a typo.
    >
    > John Saunders
    >
    >
    >
     
    Mike MacMillan, Jan 8, 2005
    #5
    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. tshad

    button visible/not visible

    tshad, Oct 26, 2004, in forum: ASP .Net
    Replies:
    6
    Views:
    4,503
    Brian Hoops
    Oct 28, 2004
  2. tshad

    Sections visible and not visible

    tshad, Jan 31, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    2,092
    tshad
    Jan 31, 2005
  3. Patrick Olurotimi Ige
    Replies:
    7
    Views:
    6,054
    Patrick Olurotimi Ige
    Jun 15, 2005
  4. tshad
    Replies:
    1
    Views:
    4,343
    tshad
    Oct 31, 2009
  5. Jurjen de Groot
    Replies:
    0
    Views:
    335
    Jurjen de Groot
    May 19, 2008
Loading...

Share This Page