Home All Groups Group Topic Archive Search About
Author
20 Jun 2006 8:25 AM
Peter Kirk
Hi there

I am trying to write some "web user controls" which I want to include on an
aspx.

In my VS2005 solution I have a project with my aspx, and another project
with my user controls (ascxs). But I can't compile my solution because the
aspx complains that it can see the ascxs. I get an error like:

Element 'MyControl' is not a known element. This can occur if there is a
compilation error in the Web site.
File 'MyControl.ascx' was not found.

Do the ascxs have to sit in the same project as the aspx?

My aspx looks like this:

<%@ Register TagPrefix="uc" TagName="MyControl" Src="MyControl.ascx" %>

<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="ControlTest.aspx.cs"
Inherits="alphasolutions.web.control.test.ControlTest" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Test Input</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <uc:MyControl id="a_control" runat="server" />
    </div>
    </form>
</body>
</html>



Thanks,
Peter

Author
20 Jun 2006 8:36 AM
Jeppe Jespersen
>
> Do the ascxs have to sit in the same project as the aspx?
>

I'm pretty sure I read somewhere that ascx's are not "real" re-useable, but
only copy/paste re-useable.
So my answer would be yes, they do need to be in the same project.

/jespersen
Denmark
Author
21 Jun 2006 7:23 AM
Peter Kirk
"Jeppe Jespersen" <jdj curlythingie jdj dot dk> skrev i en meddelelse
news:%23boWXSElGHA.4828@TK2MSFTNGP04.phx.gbl...
> >
>> Do the ascxs have to sit in the same project as the aspx?
>>
>
> I'm pretty sure I read somewhere that ascx's are not "real" re-useable,
> but only copy/paste re-useable.
> So my answer would be yes, they do need to be in the same project.
>
> /jespersen
> Denmark

Tak, Jeppe!

mvh,
Peter (Danmark).
Author
21 Jun 2006 5:23 AM
Steve C. Orr [MVP, MCSD]
Yes, they need to be in the same project.  This is the only supported way to
do it, although I've heard of unsupported techniques such as using shared
virtual directories for the user controls.
For high quality reusability you should create custom controls, not user
controls.
Here's more info:
http://SteveOrr.net/faq/UserCustom.aspx

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



Show quoteHide quote
"Peter Kirk" <p*@alpha-solutions.dk> wrote in message
news:%2319rmMElGHA.5072@TK2MSFTNGP04.phx.gbl...
> Hi there
>
> I am trying to write some "web user controls" which I want to include on
> an aspx.
>
> In my VS2005 solution I have a project with my aspx, and another project
> with my user controls (ascxs). But I can't compile my solution because the
> aspx complains that it can see the ascxs. I get an error like:
>
> Element 'MyControl' is not a known element. This can occur if there is a
> compilation error in the Web site.
> File 'MyControl.ascx' was not found.
>
> Do the ascxs have to sit in the same project as the aspx?
>
> My aspx looks like this:
>
> <%@ Register TagPrefix="uc" TagName="MyControl" Src="MyControl.ascx" %>
>
> <%@ Page Language="C#" AutoEventWireup="true"
> CodeBehind="ControlTest.aspx.cs"
> Inherits="alphasolutions.web.control.test.ControlTest" %>
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>
> <html xmlns="http://www.w3.org/1999/xhtml" >
> <head runat="server">
>    <title>Test Input</title>
> </head>
> <body>
>    <form id="form1" runat="server">
>    <div>
>        <uc:MyControl id="a_control" runat="server" />
>    </div>
>    </form>
> </body>
> </html>
>
>
>
> Thanks,
> Peter
>
Author
21 Jun 2006 7:24 AM
Peter Kirk
Show quote Hide quote
"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> skrev i en meddelelse
news:uSiBbLPlGHA.508@TK2MSFTNGP03.phx.gbl...
> Yes, they need to be in the same project.  This is the only supported way
> to do it, although I've heard of unsupported techniques such as using
> shared virtual directories for the user controls.
> For high quality reusability you should create custom controls, not user
> controls.
> Here's more info:
> http://SteveOrr.net/faq/UserCustom.aspx
>
> --
> I hope this helps,
> Steve C. Orr, MCSD, MVP
> http://SteveOrr.net

Great, thanks for the info. I think I'll stick with the user-controls for
the moment, and live with the "restriction".

Thanks,
Peter