473,698 Members | 2,162 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Avoiding @Register, cannot instantiate controls registered in web.config (2.0)

I'm fond of web controls in ASP.NET, but the need for <@ Register%>
blocks at the top of each page is a pain.

ASP.NET 2.0 has a way to centrally register controls in the web.config
file, but it is poorly documented and appears to be broken.

I have added my standard user controls to my web.config file. The MSDN
examples are flat wrong, by the way (bad XML case and attribute names,
won't compile). The proper syntax for registering server and user
controls is as follows:

<configuration> <system.web><pa ges><controls>
<add tagPrefix="RST" namespace="RST. UI" assembly="RST.U I" />
<add tagPrefix="RST" tagName="Header "
src="~/controls/header.ascx" />
</controls></pages></system.web></configuration>

Ok, so now I can use declarative instantiation on any ASPX page,
without the need for a page-level @Register directive:

<RST:Header runat="server" id="MyHeader" />

And, with at least one instance of a particular control created that
way, I can programmaticall y create others:

Public Sub Page_Load()
' ClassName="Head er" in the header.ascx
Dim o As New ASP.Header
End Sub

The problem is, I am usually creating *every* instance of some controls
dynamically in the Page_Load() method. But without at least one
declarative instance or an @Register directive, I get the following
error:

Type 'ASP.MyHeader' is not defined.

What am I missing here? Creating dummy instances of every control class
is even worse than having an army of @Register directives on every page.

Jan 27 '06 #1
5 1843
I will admit that I have not tried using web.config in place of the
@register directive, but in your example you have an attribute of

assembly="RST.U I"

I could be wrong, but aren't assemblies usually .dll files? I think that
there might be a way to add a line in the AssemblyInfo.vb (or whatever file)
file that does what you want. Try looking into that, although I won't make
any promises since I prefer the simple @register technique, I don't think
it's that bad when all you have to do is a little copy & pasting. Good Luck!
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/

<ri************ *@gmail.com> wrote in message
news:11******** *************@g 49g2000cwa.goog legroups.com...
I'm fond of web controls in ASP.NET, but the need for <@ Register%>
blocks at the top of each page is a pain.

ASP.NET 2.0 has a way to centrally register controls in the web.config
file, but it is poorly documented and appears to be broken.

I have added my standard user controls to my web.config file. The MSDN
examples are flat wrong, by the way (bad XML case and attribute names,
won't compile). The proper syntax for registering server and user
controls is as follows:

<configuration> <system.web><pa ges><controls>
<add tagPrefix="RST" namespace="RST. UI" assembly="RST.U I" />
<add tagPrefix="RST" tagName="Header "
src="~/controls/header.ascx" />
</controls></pages></system.web></configuration>

Ok, so now I can use declarative instantiation on any ASPX page,
without the need for a page-level @Register directive:

<RST:Header runat="server" id="MyHeader" />

And, with at least one instance of a particular control created that
way, I can programmaticall y create others:

Public Sub Page_Load()
' ClassName="Head er" in the header.ascx
Dim o As New ASP.Header
End Sub

The problem is, I am usually creating *every* instance of some controls
dynamically in the Page_Load() method. But without at least one
declarative instance or an @Register directive, I get the following
error:

Type 'ASP.MyHeader' is not defined.

What am I missing here? Creating dummy instances of every control class
is even worse than having an army of @Register directives on every page.

Jan 28 '06 #2
The assembly name is "RST.UI.dll ", and the register directive leaves
off the DLL. But this issue applies both to DLL and ASCX controls.

Copy and paste is never a good programming practice. I make heavy use
of custom controls, so centralization is a key requirement, and I don't
want to give up using ASCX files in the process.

Jan 30 '06 #3
Did you try looking into a way of adding something to the AssemblyInfo.dl l
file that accomplishes what you want? I'm not sure exactly what it would be,
but I seem to remember reading something about a way to use AssemblyInfo.dl l
that might accomplish what you want.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/

<ri************ *@gmail.com> wrote in message
news:11******** **************@ g49g2000cwa.goo glegroups.com.. .
The assembly name is "RST.UI.dll ", and the register directive leaves
off the DLL. But this issue applies both to DLL and ASCX controls.

Copy and paste is never a good programming practice. I make heavy use
of custom controls, so centralization is a key requirement, and I don't
want to give up using ASCX files in the process.

Jan 30 '06 #4
Nathan, thanks, but I think you are missing the point. ASCX files don't
*have* an AssemblyInfo.dl l file, they are standalone, plain-text files
that are compiled dynamically by ASP.NET.

ASP.NET is supposed to offer this functionality now via the web.config
file, but it appears to not work as advertised, and the SDK
documentation is completely useless.

Jan 31 '06 #5
I apologize, I meant to say the AssemblyInfo.vb file. This is a file
required by all ASP.NET applications written in VB.NET (if you are using C#
it is called AssemblyInfo.cs ). Like I have mentioned before, I have never
modified this file, so I don't know everything that can be put in it or what
it can be used for, I am simply suggesting that you look into it.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/

<ri************ *@gmail.com> wrote in message
news:11******** **************@ g44g2000cwa.goo glegroups.com.. .
Nathan, thanks, but I think you are missing the point. ASCX files don't
*have* an AssemblyInfo.dl l file, they are standalone, plain-text files
that are compiled dynamically by ASP.NET.

ASP.NET is supposed to offer this functionality now via the web.config
file, but it appears to not work as advertised, and the SDK
documentation is completely useless.

Feb 1 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
775
by: Carel Lotz | last post by:
H We have ported our VB 6 application into VB .NET but are still integrating with a few COM + applications written in VB6 running on our application server (Win 2000 Server). We have the proxies to link to the application server installed but we every now and then get a error when we try to make a call to a component running on the app server. The error message is something like Object reference not set to an instance of an objec at...
3
17454
by: ernesto | last post by:
Hi everybody: I have the following implementations: class A { public: virtual int GetValue() = 0; };
4
1953
by: Bobby C. Jones | last post by:
I'm trying to use some classes defined in a COM component that I did not create. I have successfully created the RCW via Tlbimp.exe and referenced it in my project. All is well until I run the project and it chokes with an "Invalid access to memory location." error when I try to instantiate an object like so: AecXSchedule30.AecAnchorTagToEntClass anchor = new AecXSchedule30.AecAnchorTagToEntClass(); I'm not sure where the best place...
7
10561
by: Simon Bond | last post by:
In C# we can go: <foo.cs> // Create a serializable class public class Foo : ISerializable { public void GetObjectData(SerializationInfo info, StreamingContext context) {};
1
2823
by: Andreas Poller | last post by:
Hello, I have the following problem: I have a class deriving from ICustomTypeDescriptor: public __gc class TPropertyBag : public ICustomTypeDescriptor { private: ...
0
965
by: Primoz Gustincic | last post by:
I'm explicitly implementing an interface defined in assembly A. public __gc __interface IPop { Void GetPop(); }; public __abstract __gc class CPOP : public IPop { private:
5
5450
by: Lauxa | last post by:
I am hosted on GoDaddy (Linux) and I am trying to use the ZipArchive php classes. I called GoDaddy technical support and asked if they supported the ZipArchive classes and they said yes. I cannot get it to work; I am down to a single line of code in a test file: <?php $zip = new ZipArchive; ?> Which fails with the following error: Fatal error: Cannot instantiate non-existent class: ziparchive in...
4
4069
by: pedro | last post by:
application cannot read the app.config file i have a config file for the executable i try to read it but it throws an exception when building the setup for the project vs2005 do not add the app.config automatically public Form1()
1
6433
by: jainchar | last post by:
hello i m in trouble that my project is in vc++ with mfc.my program giving the error that error c2259:"CException" cannot instantiate abstract class. when i remove this error then my project is giving the error in file afxres.rc .according to the error when i remove it and compile or debug the project then this can't save.so what should i do.please help me and can somebody give me the guideline that what is the afxres.rc file.
0
8673
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9156
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9021
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8860
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7716
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6518
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4365
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2327
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1998
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.