R
richard.tallent
ASP.NET 2.0 has a way to centrally register user controls (ASCX) in the
web.config file, but it is poorly documented and appears to be broken.
Can anyone confirm the issue or suggest a fix?
The SDK documentation examples have bad XML case and attribute names.
The following example allows the application to start without errors:
<configuration><system.web><pages><controls>
<add tagPrefix="RST" tagName="Header" src="~/controls/header.ascx"
/>
</controls></pages></system.web></configuration>
After that, any ASPX page can create an instance of the control via
ASP.NET markup without having to have an "@Register" directive.
Example:
<RST:Header runat="server" id="MyHeader" />
The problem comes when an ASPX page does not instantiate the control by
markup, but rather by direct code:
Public Sub Page_Load()
Dim o As New ASP.Header ' ClassName="Header" in the header.ascx
End Sub
This results in the following error:
Type 'ASP.MyHeader' is not defined.
Oddly enough, if at least one instance of the control is created
through markup, any number of other instances can be created in code
using code like the example above.
Is this a bug? If not, where did I go wrong?
(Apologies to readers of mpdfa, I posted a similar message a few days
ago there, got no useful response, and then saw this group and decided
it would be a better fit.)
web.config file, but it is poorly documented and appears to be broken.
Can anyone confirm the issue or suggest a fix?
The SDK documentation examples have bad XML case and attribute names.
The following example allows the application to start without errors:
<configuration><system.web><pages><controls>
<add tagPrefix="RST" tagName="Header" src="~/controls/header.ascx"
/>
</controls></pages></system.web></configuration>
After that, any ASPX page can create an instance of the control via
ASP.NET markup without having to have an "@Register" directive.
Example:
<RST:Header runat="server" id="MyHeader" />
The problem comes when an ASPX page does not instantiate the control by
markup, but rather by direct code:
Public Sub Page_Load()
Dim o As New ASP.Header ' ClassName="Header" in the header.ascx
End Sub
This results in the following error:
Type 'ASP.MyHeader' is not defined.
Oddly enough, if at least one instance of the control is created
through markup, any number of other instances can be created in code
using code like the example above.
Is this a bug? If not, where did I go wrong?
(Apologies to readers of mpdfa, I posted a similar message a few days
ago there, got no useful response, and then saw this group and decided
it would be a better fit.)