Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > aspx and ascx

Reply
Thread Tools

aspx and ascx

 
 
Peter Kirk
Guest
Posts: n/a
 
      06-20-2006
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.ControlT est" %>

<!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


 
Reply With Quote
 
 
 
 
Jeppe Jespersen
Guest
Posts: n/a
 
      06-20-2006
>
> 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




 
Reply With Quote
 
 
 
 
Steve C. Orr [MVP, MCSD]
Guest
Posts: n/a
 
      06-21-2006
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



"Peter Kirk" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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.ControlT est" %>
>
> <!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
>



 
Reply With Quote
 
Peter Kirk
Guest
Posts: n/a
 
      06-21-2006
"Jeppe Jespersen" <jdj curlythingie jdj dot dk> skrev i en meddelelse
news:%(E-Mail Removed)...
> >
>> 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).


 
Reply With Quote
 
Peter Kirk
Guest
Posts: n/a
 
      06-21-2006

"Steve C. Orr [MVP, MCSD]" <(E-Mail Removed)> skrev i en meddelelse
news:(E-Mail Removed)...
> 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


 
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
TabStrip/Multipage using UserControl (.ascx) contained within a UserControl(.ascx) shaileenpatel@yahoo.com ASP .Net Web Controls 2 05-03-2005 05:01 PM
Multiple *.ascx files with a single *.ascx.cs in VS.NET 2003 Holger (David) Wagner ASP .Net 2 07-03-2004 09:23 AM
datasource of child .ascx not visible to parent .ascx Joe ASP .Net Web Controls 1 02-16-2004 07:27 AM
can a dg be added to an ascx? ascx call a ws? Jason Shohet ASP .Net 1 11-10-2003 07:08 PM
[ASCX] Add an ascx in a webcontrol... Quentin ASP .Net 1 07-29-2003 07:37 PM



Advertisments