Multiple controls, Same name

M

Michael Tissington

I have created multiple controls with the same name but in different
namespaces (each one in a different folder)

I now need to reference these controls on a single web page but when I try
to browse the page I get errors saying the the control is defined more than
once.

How do I make each reference specific?

This is what I have at the moment

<@ Register TagPrefix="uc1" TagName="Test1" Src="/Test1/Description.ascx"
%>
<@ Register TagPrefix="uc1" TagName="Test2" Src="/Test2/Description.ascx"
%>
<@ Register TagPrefix="uc1" TagName="Test3" Src="/Test3/Description.ascx"
%>
 
V

Victor Garcia Aprea [MVP]

Hi Michael,

What you're seeing is okay and it has to do with the way the parser generate
implicit class names. You could use the ClassName attribute in the @Control
directive of your .ascx to avoid having duplicate names.

--
Victor Garcia Aprea
Microsoft MVP | ASP.NET
Looking for insights on ASP.NET? Read my blog:
http://obies.com/vga/blog.aspx
To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
and not by private mail.
 
V

Victor Garcia Aprea [MVP]

Hi Michael,

What you're seeing is okay and it has to do with the way the parser generate
implicit class names. You could use the ClassName attribute in the @Control
directive of your .ascx to avoid having duplicate names.

--
Victor Garcia Aprea
Microsoft MVP | ASP.NET
Looking for insights on ASP.NET? Read my blog:
http://obies.com/vga/blog.aspx
To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
and not by private mail.
 
B

Bradley Jiang[MSFT]

Hi,

I agree with Victor.

When ASP .NET parse the application, by default it will create the class of
the corresponding control with the name of the control¡¯s file name. If the
file names of the controls are the same, classes with the same name will be
created and the error will occur. If you go to the folder
Windows\Microsoft.NET\Framework\<version>\Temporary ASP.NET Files\<random
number>, you will find several *.vb or *.cs files. These files are the
results of the parsing. You will notice that in these .VB or .CS files,
Description_ascx class may have been defined several times.

To resolve the issue, add a ¡°ClassName=¡± attribute to the @Control
reference in the ascx :

<%@ Control ClassName="myclass1" Language="vb"¡­

Name the controls different names as ClassName. We don¡¯t need to modify
the aspx file.


Best regards,
Bradley Jiang

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
|From: "Michael Tissington" <[email protected]>
|Subject: Multiple controls, Same name
|Date: Sun, 13 Jul 2003 21:26:49 -0700
|Lines: 25
|X-Priority: 3
|X-MSMail-Priority: Normal
|X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
|X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
|Message-ID: <#[email protected]>
|Newsgroups:
microsoft.public.dotnet.framework.aspnet.buildingcontrols,microsoft.public.d
otnet.framework.aspnet.webcontrols
|NNTP-Posting-Host: antelope.oaklodge.com 63.67.71.5
|Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl
|Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.aspnet.webcontrols:13074
microsoft.public.dotnet.framework.aspnet.buildingcontrols:6570
|X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.buildingcontrols
|
|I have created multiple controls with the same name but in different
|namespaces (each one in a different folder)
|
|I now need to reference these controls on a single web page but when I try
|to browse the page I get errors saying the the control is defined more than
|once.
|
|How do I make each reference specific?
|
|This is what I have at the moment
|
|<@ Register TagPrefix="uc1" TagName="Test1" Src="/Test1/Description.ascx"
|%>
|<@ Register TagPrefix="uc1" TagName="Test2" Src="/Test2/Description.ascx"
|%>
|<@ Register TagPrefix="uc1" TagName="Test3" Src="/Test3/Description.ascx"
|%>
|
|--
|Michael Tissington
|Oaklodge Technologies
|http://www.oaklodge.com/technology
|
|
|
|
 

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

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top