Multiple controls, Same name

Discussion in 'ASP .Net Building Controls' started by Michael Tissington, Jul 14, 2003.

  1. 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
    Michael Tissington, Jul 14, 2003
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:%...
    > 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
    >
    >
    >
    Victor Garcia Aprea [MVP], Jul 15, 2003
    #2
    1. Advertising

  3. 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" <> wrote in message
    news:%...
    > 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
    >
    >
    >
    Victor Garcia Aprea [MVP], Jul 15, 2003
    #3
  4. Thanks

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

    "Victor Garcia Aprea [MVP]" <> wrote in message
    news:...
    > 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" <> wrote in message
    > news:%...
    > > 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
    > >
    > >
    > >

    >
    >
    Michael Tissington, Jul 15, 2003
    #4
  5. 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" <>
    |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: <#>
    |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
    |
    |
    |
    |
    Bradley Jiang[MSFT], Jul 18, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jeff Tolman
    Replies:
    0
    Views:
    2,957
    Jeff Tolman
    Nov 4, 2003
  2. Replies:
    3
    Views:
    478
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    May 16, 2006
  3. Replies:
    5
    Views:
    331
    Alf P. Steinbach
    Feb 6, 2006
  4. rodchar

    mvc same name same post

    rodchar, Oct 8, 2009, in forum: ASP .Net
    Replies:
    0
    Views:
    279
    rodchar
    Oct 8, 2009
  5. Michael Tissington

    Multiple controls, Same name

    Michael Tissington, Jul 14, 2003, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    149
    Michael Tissington
    Jul 15, 2003
Loading...

Share This Page