Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > class is not visible

Reply
Thread Tools

class is not visible

 
 
Lubomir
Guest
Posts: n/a
 
      01-05-2005
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

 
Reply With Quote
 
 
 
 
John Saunders
Guest
Posts: n/a
 
      01-06-2005
"Lubomir" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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


 
Reply With Quote
 
 
 
 
Lubomir
Guest
Posts: n/a
 
      01-06-2005
"John Saunders" wrote:

> "Lubomir" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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 ":"
 
Reply With Quote
 
John Saunders
Guest
Posts: n/a
 
      01-06-2005
"Lubomir" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "John Saunders" wrote:
>
>> "Lubomir" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> > 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



 
Reply With Quote
 
Mike MacMillan
Guest
Posts: n/a
 
      01-08-2005
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:%(E-Mail Removed)...
> "Lubomir" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > "John Saunders" wrote:
> >
> >> "Lubomir" <(E-Mail Removed)> wrote in message
> >> news:(E-Mail Removed)...
> >> > 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
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Input button visible when not visible tshad ASP .Net 1 10-31-2009 10:53 PM
Hide textbox / Make textbox not visible (NOT USING visible property) Jurjen de Groot ASP .Net Web Controls 0 05-19-2008 09:50 AM
How to make a hyperlink Visible or not visible in DataList Patrick Olurotimi Ige ASP .Net 7 06-15-2005 12:01 PM
Sections visible and not visible tshad ASP .Net 4 01-31-2005 09:30 PM
button visible/not visible tshad ASP .Net 6 10-28-2004 10:02 PM



Advertisments