all groups > asp.net webcontrols > april 2006 >
You're in the

asp.net webcontrols

group:

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


Automatic <%@Register of Web User Controls in a Project? Alex Maghen
4/29/2006 7:05:01 AM
asp.net webcontrols:
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
Re: Automatic <%@Register of Web User Controls in a Project? Alex Maghen
4/29/2006 11:07:02 AM
That rocks! Thanks.

[quoted text, click to view]
Re: Automatic <%@Register of Web User Controls in a Project? gerry
4/29/2006 3:03:02 PM
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




[quoted text, click to view]

Re: Automatic <%@Register of Web User Controls in a Project? Teemu Keiski
4/29/2006 8:23:46 PM
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

[quoted text, click to view]

Re: Automatic <%@Register of Web User Controls in a Project? Teemu Keiski
4/30/2006 12:00:00 AM
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


[quoted text, click to view]

Re: Automatic <%@Register of Web User Controls in a Project? gerry
4/30/2006 2:31:11 PM
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 ?



[quoted text, click to view]

Re: Automatic <%@Register of Web User Controls in a Project? Teemu Keiski
5/1/2006 1:09:12 AM
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

[quoted text, click to view]

Re: Automatic <%@Register of Web User Controls in a Project? stcheng NO[at]SPAM online.microsoft.com
5/1/2006 1:33:02 AM
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.)

AddThis Social Bookmark Button