I will admit that I have not tried using web.config in place of the
@register directive, but in your example you have an attribute of
assembly="RST.UI"
I could be wrong, but aren't assemblies usually .dll files? I think that
there might be a way to add a line in the AssemblyInfo.vb (or whatever file)
file that does what you want. Try looking into that, although I won't make
any promises since I prefer the simple @register technique, I don't think
it's that bad when all you have to do is a little copy & pasting. Good Luck!
--
Nathan Sokalski
njsokalski@hotmail.com http://www.nathansokalski.com/
<richard.tallent@gmail.com> wrote in message
news:1138401144.585006.15990@g49g2000cwa.googlegro ups.com...[color=blue]
> I'm fond of web controls in ASP.NET, but the need for <@ Register%>
> blocks at the top of each page is a pain.
>
> ASP.NET 2.0 has a way to centrally register controls in the web.config
> file, but it is poorly documented and appears to be broken.
>
> I have added my standard user controls to my web.config file. The MSDN
> examples are flat wrong, by the way (bad XML case and attribute names,
> won't compile). The proper syntax for registering server and user
> controls is as follows:
>
> <configuration><system.web><pages><controls>
> <add tagPrefix="RST" namespace="RST.UI" assembly="RST.UI" />
> <add tagPrefix="RST" tagName="Header"
> src="~/controls/header.ascx" />
> </controls></pages></system.web></configuration>
>
> Ok, so now I can use declarative instantiation on any ASPX page,
> without the need for a page-level @Register directive:
>
> <RST:Header runat="server" id="MyHeader" />
>
> And, with at least one instance of a particular control created that
> way, I can programmatically create others:
>
> Public Sub Page_Load()
> ' ClassName="Header" in the header.ascx
> Dim o As New ASP.Header
> End Sub
>
> The problem is, I am usually creating *every* instance of some controls
> dynamically in the Page_Load() method. But without at least one
> declarative instance or an @Register directive, I get the following
> error:
>
> Type 'ASP.MyHeader' is not defined.
>
> What am I missing here? Creating dummy instances of every control class
> is even worse than having an army of @Register directives on every page.
>[/color]