Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Register User Control for ALL pages in a site

Reply
Thread Tools

Register User Control for ALL pages in a site

 
 
David Bowey
Guest
Posts: n/a
 
      03-09-2005
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


 
Reply With Quote
 
 
 
 
quaester
Guest
Posts: n/a
 
      03-09-2005
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>


"David Bowey" wrote:

> 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
>
>
>

 
Reply With Quote
 
 
 
 
David Bowey
Guest
Posts: n/a
 
      03-09-2005
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

"quaester" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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>
>
>
> "David Bowey" wrote:
>
>> 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
>>
>>
>>



 
Reply With Quote
 
quaester
Guest
Posts: n/a
 
      03-09-2005
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..

"David Bowey" wrote:

> 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
>
> "quaester" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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>
> >
> >
> > "David Bowey" wrote:
> >
> >> 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
> >>
> >>
> >>

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Web.config's <system.web><pages><controls><add /></controls></pages></system.web> To Register UserControls Nathan Sokalski ASP .Net 5 01-10-2007 10:50 AM
Using Web.config's <system.web><pages><controls><add /></controls></pages></system.web> To Register UserControls Nathan Sokalski ASP .Net Web Controls 4 12-21-2006 02:50 AM
Using Web.config's <system.web><pages><controls><add /></controls></pages></system.web> To Register UserControls Nathan Sokalski ASP .Net Building Controls 4 12-21-2006 02:50 AM
persisting changes to a control outside a user control from the user control? Mad Scientist Jr ASP .Net 0 03-22-2006 08:02 AM
Register User Control for ALL pages in a site David Bowey ASP .Net Building Controls 3 03-09-2005 11:57 AM



Advertisments