Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > Multiple controls, Same name

Reply
Thread Tools

Multiple controls, Same name

 
 
Michael Tissington
Guest
Posts: n/a
 
      07-14-2003
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



 
Reply With Quote
 
 
 
 
Victor Garcia Aprea [MVP]
Guest
Posts: n/a
 
      07-15-2003
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.

"Michael Tissington" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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
>
>
>



 
Reply With Quote
 
 
 
 
Victor Garcia Aprea [MVP]
Guest
Posts: n/a
 
      07-15-2003
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.

"Michael Tissington" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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
>
>
>



 
Reply With Quote
 
Michael Tissington
Guest
Posts: n/a
 
      07-15-2003
Thanks

--
Michael Tissington
Oaklodge Technologies
http://www.oaklodge.com/technology

"Victor Garcia Aprea [MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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.
>
> "Michael Tissington" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > 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
> >
> >
> >

>
>



 
Reply With Quote
 
Bradley Jiang[MSFT]
Guest
Posts: n/a
 
      07-18-2003
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>\Temporar y 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" <(E-Mail Removed)>
|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: <#(E-Mail Removed)>
|Newsgroups:
microsoft.public.dotnet.framework.aspnet.buildingc ontrols,microsoft.public.d
otnet.framework.aspnet.webcontrols
|NNTP-Posting-Host: antelope.oaklodge.com 63.67.71.5
|Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftn gp13.phx.gbl
|Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.aspnet.webcontro ls:13074
microsoft.public.dotnet.framework.aspnet.buildingc ontrols:6570
|X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.buildingc ontrols
|
|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
|
|
|
|

 
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
mvc same name same post rodchar ASP .Net 0 10-08-2009 08:43 PM
User Controls with same name on same page rgparkins@hotmail.com ASP .Net 3 05-16-2006 12:55 PM
Need same viewstate for same page across multiple servers =?Utf-8?B?UHVuaXNoZXI=?= ASP .Net 1 03-23-2006 03:54 PM
REQ: how to override 2 virtual functions with the same name and same parameter zzppallas@gmail.com C++ 5 02-06-2006 06:54 AM
write to the same file from multiple processes at the same time? gabor Python 19 05-31-2005 01:57 PM



Advertisments