Register User Control for ALL pages in a site

D

David Bowey

Hi There!

Typically I can register a user control for a page using...

<%@ Register TagPrefix="myControls" Src="controls/test.ascx" TagName="test"
%>

But how do I "register" a user control so that it can be assessable from ALL
pages in the current website? Are there any configuration settings in the
web.config file that I set for this?

Creating a Custom Control (with compiled DLL) is not an option for this
project. However, I have the option to create my own base class but I have
no idea how to include a User Control from that base class. I know I can use
"LoadControl" function but I need the design-time support.

For example, a user should be able to set control's properties in an ASPX
page like this...

<myControl:test id="test1" runat="server"
myProperty1="test"
myProperty2="test"></myControl:test>

without having to declare "Register" directive at the top of the page. So
"LoadControl" is no go.

Any pointers will be much appreciated!

Dave
 
Q

quaester

Yes! you can do that by adding the following in your web.config.
(or even machine.config if you want to apply to the entire machine, but not
wise to do so)

<configuration>
<system.web>
<pages>
<controls>
<add TagPrefix="myControls" Src="controls/test.ascx"
TagName="test"/>
</controls>
</pages>
</system.web>
</configuration>
 
D

David Bowey

Thanks for the reply! However, a few problems...

I added the following code to web.config file...

<configuration>
<system.web>
<pages>
<controls>
<add TagPrefix="myControls" Src="controls/test.ascx"
TagName="test"/>
</controls>
</pages>
</system.web>
</configuration>

However, I'm getting the following error...

Parser Error Message: Child nodes are not allowed.

at the line where "<controls>" is wirtten...

Any ideas? Is it because I'm using ASP.NET 1.1?

Thanks again!
Dave
 
Q

quaester

Did you add in to the wrong part of your web.config?
in your web.config there should have the <configuration><system.web>, you'll
just need to add in the hierarchy.
Sorry to say, I'm using .net 2.0, I've looked up the msdn and it doesn't
seems to appear for 1.1..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top