I'm playing with Visual Web Developer 2005 Express Edition, coming from VisualStudio 2003.net.
I have a user control in the [application root]/util/controls directory. I have another control in that directory that needs to use the first control. I have in the ascx file of the second control the following line:
<%@dotnet.itags.org. Register TagPrefix="uc2" TagName="BannerTop" src="http://pics.10026.com/?src=/Util/Controls/BannerTop.ascx" %>
When I try to use the control (<uc2:BannerTopID="BannerTop1"runat="server"/>)I get an error saying that the file located at ~Util/Controls/Util/Controls/BannerTop.ascx could not be found (NOTE the duplicated path and the ~, I think indicating that it's trying to do a relative path).
WHY? Who the heck told it to use a relative path (NOTE the "/" at the beginning of the SRC line!)
Even when I delete the embedded control and then drag it in using the Visual Web Developer 2005 express edition, it does the same thing! Very frustrating
Am I missing something?
TIA,
When I try to use the control (<uc2:BannerTopID="BannerTop1"runat="server"/>)
What exactly do you mean by this? Are you trying to reference this control in code?
I'm trying to put the control on the web page in the aspx file. Did this syntax radically change with 2.0?
Pretty standard syntax in 1.1 to put a user control on a web page (See page 63 of the Microsoft Press book "Developing Microsoft ASP.Net Server Controls and Components" by Kothari and Datye)... I use it all over my 1.1 site....
For example:
<%@.PageLanguage="vb"AutoEventWireup="false"Inherits="cwsBackOffice.index"CodeFile="index.aspx.vb" %>
<%@.RegisterSrc="/Util/Controls/cwsbackofficecontainer.ascx"TagName="cwsbackofficecontainer"TagPrefix="uc1" %>
<!DOCTYPEHTMLPUBLIC"-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>
index
</title>
<body>
<formid="Form1"method="post"runat="server">
<uc1:cwsbackofficecontainerid="Cwsbackofficecontainer1"runat="server">
</uc1:cwsbackofficecontainer>
</form>
</body>
One thing I notice is that when dragging a UC into a Web Form (Html View or Design View doesn't matter in VS 2005), the Tilde (~) is inserted by default. This makes sense as Physical Path detection with the advent of Master Pages and storing systems for UCs etc should not be a concern of the developer. Example below showing how the .ascx file is referenced in VS2005 (drag'n drop):
<%@.RegisterSrc="~/UserControls/UC_Newsmodule.ascx"TagName="newsmodule"TagPrefix="uc2"%>
Doesn't work for me, though (with a VS2003 converted project anyway). I drag it in, I get the "~/UserControls/whatever.ascx" line, but then the compiler complains that "/UserControls/UserControls/whatever.ascx" cannot be found... I went in and hand edited the line, removing the tilde, and that part worked.
Except now it still insists that it doesn't know what the TagName objectis.
I think the problem lies in that the new Visual Web Developer doesn't know which parts of the project are code-library-type-things and which are web pages, etc. The project this was converted from used several code-library objects (written by us, compiled as part of the project) that seem to have been just copied to the new web project with no information provided to the web project as to how to use them (as objects!).
For instance, we have an in-house membership object called Membership.member. In the VS2003 source project, it is identified as a separate VB project (code-library) that is then referenced in the web project. How do I do this in the new Visual Web Developer 2005? I can't seem to add a code-library object to the project.
cheers,
0 comments:
Post a Comment