Home All Groups Group Topic Archive Search About

Automatic <%@Register of Web User Controls in a Project?

Author
29 Apr 2006 2:05 PM
Alex Maghen
Hi. In the shiny new ASP.NET 2.0, if you have a web project and you create a
set of User WebControls, is there a way to set those controls so that I don't
have to insert the whole
<%@ Register tagprefix="XYZ" Tagname="MyControl"
               Src="~/BlahBlah/MyControl.ascx" %>

at the top of every page in order to use the control on that page? I *think*
I remember that there's a way of installing the control "globally" for the
whole server machine. I really don't want to do that. I just want to make it
accessible to the project without the whole ugly <%@Register tag.

Author
29 Apr 2006 5:23 PM
Teemu Keiski
Hi,

yes. It's been added that you can specify global control registration in
web.config (for your web app). For example:

<pages>
      <controls>

         <!-- Uses the specified source for the user control -->
         <add
            tagprefix="MyTags3"
            tagname="MyCtrl"
            source="MyControl.ascx"/>
      </controls>
   </pages>

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke

Show quoteHide quote
"Alex Maghen" <AlexMaghen@newsgroup.nospam> wrote in message
news:7F451A48-C6F0-4533-A6CA-EF102B2FA39F@microsoft.com...
> Hi. In the shiny new ASP.NET 2.0, if you have a web project and you create
> a
> set of User WebControls, is there a way to set those controls so that I
> don't
> have to insert the whole
> <%@ Register tagprefix="XYZ" Tagname="MyControl"
>               Src="~/BlahBlah/MyControl.ascx" %>
>
> at the top of every page in order to use the control on that page? I
> *think*
> I remember that there's a way of installing the control "globally" for the
> whole server machine. I really don't want to do that. I just want to make
> it
> accessible to the project without the whole ugly <%@Register tag.
Author
29 Apr 2006 6:07 PM
Alex Maghen
That rocks! Thanks.

Show quoteHide quote
"Teemu Keiski" wrote:

> Hi,
>
> yes. It's been added that you can specify global control registration in
> web.config (for your web app). For example:
>
> <pages>
>       <controls>
>
>          <!-- Uses the specified source for the user control -->
>          <add
>             tagprefix="MyTags3"
>             tagname="MyCtrl"
>             source="MyControl.ascx"/>
>       </controls>
>    </pages>
>
> --
> Teemu Keiski
> ASP.NET MVP, AspInsider
> Finland, EU
> http://blogs.aspadvice.com/joteke
>
> "Alex Maghen" <AlexMaghen@newsgroup.nospam> wrote in message
> news:7F451A48-C6F0-4533-A6CA-EF102B2FA39F@microsoft.com...
> > Hi. In the shiny new ASP.NET 2.0, if you have a web project and you create
> > a
> > set of User WebControls, is there a way to set those controls so that I
> > don't
> > have to insert the whole
> > <%@ Register tagprefix="XYZ" Tagname="MyControl"
> >               Src="~/BlahBlah/MyControl.ascx" %>
> >
> > at the top of every page in order to use the control on that page? I
> > *think*
> > I remember that there's a way of installing the control "globally" for the
> > whole server machine. I really don't want to do that. I just want to make
> > it
> > accessible to the project without the whole ugly <%@Register tag.
>
>
>
Author
1 May 2006 1:33 AM
Steven Cheng[MSFT]
Thanks for Teemu's informative suggestion.

Hi Alex,

In addition to registering ascx usercontrol, the 
<system.web><pages><controls>....   </..>....   element can also be used to
register custom webserver control for application scope. So if you've
developed some custom webserver controls that'll be used in most pages in
the application, you can also consider using this configuration setting.

BTW, the <pages> setting is also configurable in sub virtual or physical
directory, therefore we can also make a certain sub virtual directory in
our application register a particular group of controls.

#controls Element for pages (ASP.NET Settings Schema)  
http://msdn2.microsoft.com/en-us/library/ms164640.aspx

Regards,

Steven Cheng
Microsoft Online Community Support


==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================


This posting is provided "AS IS" with no warranties, and confers no rights.



Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Author
29 Apr 2006 7:03 PM
gerry
Am I missing something here ?

I have a number of custom WebControls, the @ Register is added to the page
and the dll copied to the bin folder automagically just by dragging the
control onto a webform - zero manual intervention required.

???

Gerry




Show quoteHide quote
"Teemu Keiski" <jot***@aspalliance.com> wrote in message
news:%23i3GuG7aGHA.1352@TK2MSFTNGP05.phx.gbl...
> Hi,
>
> yes. It's been added that you can specify global control registration in
> web.config (for your web app). For example:
>
> <pages>
>       <controls>
>
>          <!-- Uses the specified source for the user control -->
>          <add
>             tagprefix="MyTags3"
>             tagname="MyCtrl"
>             source="MyControl.ascx"/>
>       </controls>
>    </pages>
>
> --
> Teemu Keiski
> ASP.NET MVP, AspInsider
> Finland, EU
> http://blogs.aspadvice.com/joteke
>
> "Alex Maghen" <AlexMaghen@newsgroup.nospam> wrote in message
> news:7F451A48-C6F0-4533-A6CA-EF102B2FA39F@microsoft.com...
> > Hi. In the shiny new ASP.NET 2.0, if you have a web project and you
create
> > a
> > set of User WebControls, is there a way to set those controls so that I
> > don't
> > have to insert the whole
> > <%@ Register tagprefix="XYZ" Tagname="MyControl"
> >               Src="~/BlahBlah/MyControl.ascx" %>
> >
> > at the top of every page in order to use the control on that page? I
> > *think*
> > I remember that there's a way of installing the control "globally" for
the
> > whole server machine. I really don't want to do that. I just want to
make
> > it
> > accessible to the project without the whole ugly <%@Register tag.
>
>
Author
30 Apr 2006 7:42 AM
Teemu Keiski
Certainly,

mostly a matter of preference. On the other hand, it's nice to be able to
reegister via web.config since registration is automatically applied for new
pages as well.

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke


Show quoteHide quote
"gerry" <germ@nospam.nospam> wrote in message
news:esLiL%237aGHA.2372@TK2MSFTNGP03.phx.gbl...
> Am I missing something here ?
>
> I have a number of custom WebControls, the @ Register is added to the page
> and the dll copied to the bin folder automagically just by dragging the
> control onto a webform - zero manual intervention required.
>
> ???
>
> Gerry
>
>
>
>
> "Teemu Keiski" <jot***@aspalliance.com> wrote in message
> news:%23i3GuG7aGHA.1352@TK2MSFTNGP05.phx.gbl...
>> Hi,
>>
>> yes. It's been added that you can specify global control registration in
>> web.config (for your web app). For example:
>>
>> <pages>
>>       <controls>
>>
>>          <!-- Uses the specified source for the user control -->
>>          <add
>>             tagprefix="MyTags3"
>>             tagname="MyCtrl"
>>             source="MyControl.ascx"/>
>>       </controls>
>>    </pages>
>>
>> --
>> Teemu Keiski
>> ASP.NET MVP, AspInsider
>> Finland, EU
>> http://blogs.aspadvice.com/joteke
>>
>> "Alex Maghen" <AlexMaghen@newsgroup.nospam> wrote in message
>> news:7F451A48-C6F0-4533-A6CA-EF102B2FA39F@microsoft.com...
>> > Hi. In the shiny new ASP.NET 2.0, if you have a web project and you
> create
>> > a
>> > set of User WebControls, is there a way to set those controls so that I
>> > don't
>> > have to insert the whole
>> > <%@ Register tagprefix="XYZ" Tagname="MyControl"
>> >               Src="~/BlahBlah/MyControl.ascx" %>
>> >
>> > at the top of every page in order to use the control on that page? I
>> > *think*
>> > I remember that there's a way of installing the control "globally" for
> the
>> > whole server machine. I really don't want to do that. I just want to
> make
>> > it
>> > accessible to the project without the whole ugly <%@Register tag.
>>
>>
>
>
Author
30 Apr 2006 6:31 PM
gerry
I'm not sure I understand your statement, dragging a control onto a page
does all the necessary registration - how much more automatic can you get ?



Show quoteHide quote
"Teemu Keiski" <jot***@aspalliance.com> wrote in message
news:OMcdvmCbGHA.3812@TK2MSFTNGP04.phx.gbl...
> Certainly,
>
> mostly a matter of preference. On the other hand, it's nice to be able to
> reegister via web.config since registration is automatically applied for
new
> pages as well.
>
> --
> Teemu Keiski
> ASP.NET MVP, AspInsider
> Finland, EU
> http://blogs.aspadvice.com/joteke
>
>
> "gerry" <germ@nospam.nospam> wrote in message
> news:esLiL%237aGHA.2372@TK2MSFTNGP03.phx.gbl...
> > Am I missing something here ?
> >
> > I have a number of custom WebControls, the @ Register is added to the
page
> > and the dll copied to the bin folder automagically just by dragging the
> > control onto a webform - zero manual intervention required.
> >
> > ???
> >
> > Gerry
> >
> >
> >
> >
> > "Teemu Keiski" <jot***@aspalliance.com> wrote in message
> > news:%23i3GuG7aGHA.1352@TK2MSFTNGP05.phx.gbl...
> >> Hi,
> >>
> >> yes. It's been added that you can specify global control registration
in
> >> web.config (for your web app). For example:
> >>
> >> <pages>
> >>       <controls>
> >>
> >>          <!-- Uses the specified source for the user control -->
> >>          <add
> >>             tagprefix="MyTags3"
> >>             tagname="MyCtrl"
> >>             source="MyControl.ascx"/>
> >>       </controls>
> >>    </pages>
> >>
> >> --
> >> Teemu Keiski
> >> ASP.NET MVP, AspInsider
> >> Finland, EU
> >> http://blogs.aspadvice.com/joteke
> >>
> >> "Alex Maghen" <AlexMaghen@newsgroup.nospam> wrote in message
> >> news:7F451A48-C6F0-4533-A6CA-EF102B2FA39F@microsoft.com...
> >> > Hi. In the shiny new ASP.NET 2.0, if you have a web project and you
> > create
> >> > a
> >> > set of User WebControls, is there a way to set those controls so that
I
> >> > don't
> >> > have to insert the whole
> >> > <%@ Register tagprefix="XYZ" Tagname="MyControl"
> >> >               Src="~/BlahBlah/MyControl.ascx" %>
> >> >
> >> > at the top of every page in order to use the control on that page? I
> >> > *think*
> >> > I remember that there's a way of installing the control "globally"
for
> > the
> >> > whole server machine. I really don't want to do that. I just want to
> > make
> >> > it
> >> > accessible to the project without the whole ugly <%@Register tag.
> >>
> >>
> >
> >
>
>
Author
30 Apr 2006 10:09 PM
Teemu Keiski
Yes, you are correct,

but maybe if same control is used all over the site, registration is just
cleaner to keep in one, centralized place instead on every page. Especially
if you have lots of controls used extensively on multiple pages (or all)?
Keeps the directives shorter.

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke

Show quoteHide quote
"gerry" <germ@nospam.nospam> wrote in message
news:uA0ADRIbGHA.1204@TK2MSFTNGP04.phx.gbl...
> I'm not sure I understand your statement, dragging a control onto a page
> does all the necessary registration - how much more automatic can you get
> ?
>
>
>
> "Teemu Keiski" <jot***@aspalliance.com> wrote in message
> news:OMcdvmCbGHA.3812@TK2MSFTNGP04.phx.gbl...
>> Certainly,
>>
>> mostly a matter of preference. On the other hand, it's nice to be able to
>> reegister via web.config since registration is automatically applied for
> new
>> pages as well.
>>
>> --
>> Teemu Keiski
>> ASP.NET MVP, AspInsider
>> Finland, EU
>> http://blogs.aspadvice.com/joteke
>>
>>
>> "gerry" <germ@nospam.nospam> wrote in message
>> news:esLiL%237aGHA.2372@TK2MSFTNGP03.phx.gbl...
>> > Am I missing something here ?
>> >
>> > I have a number of custom WebControls, the @ Register is added to the
> page
>> > and the dll copied to the bin folder automagically just by dragging the
>> > control onto a webform - zero manual intervention required.
>> >
>> > ???
>> >
>> > Gerry
>> >
>> >
>> >
>> >
>> > "Teemu Keiski" <jot***@aspalliance.com> wrote in message
>> > news:%23i3GuG7aGHA.1352@TK2MSFTNGP05.phx.gbl...
>> >> Hi,
>> >>
>> >> yes. It's been added that you can specify global control registration
> in
>> >> web.config (for your web app). For example:
>> >>
>> >> <pages>
>> >>       <controls>
>> >>
>> >>          <!-- Uses the specified source for the user control -->
>> >>          <add
>> >>             tagprefix="MyTags3"
>> >>             tagname="MyCtrl"
>> >>             source="MyControl.ascx"/>
>> >>       </controls>
>> >>    </pages>
>> >>
>> >> --
>> >> Teemu Keiski
>> >> ASP.NET MVP, AspInsider
>> >> Finland, EU
>> >> http://blogs.aspadvice.com/joteke
>> >>
>> >> "Alex Maghen" <AlexMaghen@newsgroup.nospam> wrote in message
>> >> news:7F451A48-C6F0-4533-A6CA-EF102B2FA39F@microsoft.com...
>> >> > Hi. In the shiny new ASP.NET 2.0, if you have a web project and you
>> > create
>> >> > a
>> >> > set of User WebControls, is there a way to set those controls so
>> >> > that
> I
>> >> > don't
>> >> > have to insert the whole
>> >> > <%@ Register tagprefix="XYZ" Tagname="MyControl"
>> >> >               Src="~/BlahBlah/MyControl.ascx" %>
>> >> >
>> >> > at the top of every page in order to use the control on that page? I
>> >> > *think*
>> >> > I remember that there's a way of installing the control "globally"
> for
>> > the
>> >> > whole server machine. I really don't want to do that. I just want to
>> > make
>> >> > it
>> >> > accessible to the project without the whole ugly <%@Register tag.
>> >>
>> >>
>> >
>> >
>>
>>
>
>