|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
aspx and ascxI 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 > I'm pretty sure I read somewhere that ascx's are not "real" re-useable, but > Do the ascxs have to sit in the same project as the aspx? > only copy/paste re-useable. So my answer would be yes, they do need to be in the same project. /jespersen Denmark "Jeppe Jespersen" <jdj curlythingie jdj dot dk> skrev i en meddelelse Tak, Jeppe!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 mvh, Peter (Danmark). 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 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 >
Show quote
Hide quote
"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> skrev i en meddelelse Great, thanks for the info. I think I'll stick with the user-controls for 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 the moment, and live with the "restriction". Thanks, Peter
Gridview right border on a per-column basis
how to get the text in JS of a cell created on server? Validators - error message not showing when JS disabled & only server side validation occurs can get forecolor but not background color in Javascript questions about Controls.add HyperLink control vs. Firefox Web User Controls(ascx) 1.1 VS 2.0 ASP.NET 2.0 Intrinsic Treeview control errors on a specific machine making a dropdownlist visible when clicking in a textbox of a detailsview? Gridview Header Template sorting |
|||||||||||||||||||||||