Home All Groups Group Topic Archive Search About

asp.net 2.0: Webcontrols in Library

Author
12 Jul 2005 9:54 AM
news.microsoft.com
Hello

I just want to re-use some of my webcontrols (*.ascx) as library. When I add
those to the library, they are automaticly splitted up into two files (as it
is also in the web-project), but there is no relation between those files.

What now happens, in ASP.NET 2.0, when I just add a label, e.g. <asp:label
id=test runat=server/> in the ascx.cs file, I directly can access the label
without defining it (as it was necessary in the 1.1). When I take that over
to the library, it just says,

"The name "test" does not exist in the current context" ... is there a way
to tell the compiler to check the ascx file in some way??

Thnx Patrick

Author
12 Jul 2005 4:43 PM
Steve C. Orr [MVP, MCSD]
User controls are not designed to be used in a control library.
For that level of reusability you should instead create custom controls.
Here are more details:
http://SteveOrr.net/faq/UserCustom.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net


Show quoteHide quote
"news.microsoft.com" <Patrick> wrote in message
news:%23YtTpeshFHA.1416@TK2MSFTNGP09.phx.gbl...
> Hello
>
> I just want to re-use some of my webcontrols (*.ascx) as library. When I
> add those to the library, they are automaticly splitted up into two files
> (as it is also in the web-project), but there is no relation between those
> files.
>
> What now happens, in ASP.NET 2.0, when I just add a label, e.g. <asp:label
> id=test runat=server/> in the ascx.cs file, I directly can access the
> label without defining it (as it was necessary in the 1.1). When I take
> that over to the library, it just says,
>
> "The name "test" does not exist in the current context" ... is there a way
> to tell the compiler to check the ascx file in some way??
>
> Thnx Patrick
>
Author
14 Jul 2005 2:05 PM
Patrick
Steve, thanks for your reply. So in that case I see, I have to rewrite my
controls, what wouldn't be a funny job, but seems to be the one and only
solution

Thanks


Show quoteHide quote
"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> schrieb im Newsbeitrag
news:uVMlJDwhFHA.1164@TK2MSFTNGP10.phx.gbl...
> User controls are not designed to be used in a control library.
> For that level of reusability you should instead create custom controls.
> Here are more details:
> http://SteveOrr.net/faq/UserCustom.aspx
>
> --
> I hope this helps,
> Steve C. Orr, MCSD, MVP
> http://SteveOrr.net
>
>
> "news.microsoft.com" <Patrick> wrote in message
> news:%23YtTpeshFHA.1416@TK2MSFTNGP09.phx.gbl...
>> Hello
>>
>> I just want to re-use some of my webcontrols (*.ascx) as library. When I
>> add those to the library, they are automaticly splitted up into two files
>> (as it is also in the web-project), but there is no relation between
>> those files.
>>
>> What now happens, in ASP.NET 2.0, when I just add a label, e.g.
>> <asp:label id=test runat=server/> in the ascx.cs file, I directly can
>> access the label without defining it (as it was necessary in the 1.1).
>> When I take that over to the library, it just says,
>>
>> "The name "test" does not exist in the current context" ... is there a
>> way to tell the compiler to check the ascx file in some way??
>>
>> Thnx Patrick
>>
>
>