....allready contains a definition for... RRS feed

  • Question

  • User-501215646 posted

    I'm trying to concert an asp.net 1.1 app. to ver. 2.0. But I keep running into one compilation error after another. Here's the one I'm battling now:

    I have two html server controls on my aspx page, wich I wish to access in my codefile:

                                <span class="dimColor">First Name:</span>
                                <input id="firstName" runat="server" class="Input" type="text" />
                                <br />
                                <span class="dimColor">Last Name:</span>
                                <input id="lastName" runat="server" class="Input" type="text" />

    To gain access to these two controls in my codefile, I create two variables:

            protected HtmlInputText firstName;
            protected HtmlInputText lastName;

    Then later in the code file, I create a StringBuilder, and append the values from the controls in the aspx page to it:

                        buffer.Append("First Name: ").Append(firstName.Value)
                        buffer.Append(", ");     
                        buffer.Append("Last Name: ").Append(lastName.Value);

    But when I try to build the app in Visual Web Developer Express, I get this error msg:

    "Error    2    The type 'UploadApp.Upload.UploadForm' already contains a definition for 'firstName'"
    "Error    3    The type 'UploadApp.Upload.UploadForm' already contains a definition for 'lastName'"

    Any ideas?
    Saturday, January 14, 2006 3:44 PM

All replies

  • User2032526919 posted

    Remove these from code-behind

             protected HtmlInputText firstName;
            protected HtmlInputText lastName;

    That's one of the changes in v2.0, you don't need to create code-behind member variables for controls.

    Reference links
    Understanding Page Inheritance in ASP.NET 2.0

    VS 2005 Web Project System: What is it and why did we do it?

    Sunday, January 15, 2006 4:24 AM
  • User-1634877164 posted

    One other resource to potentially look into if you are having a lot of problems migrating your site is the new VS 2005 Web Application Project option we are coming out with.  You can read about it and download a preview build on this website: http://webproject.scottgu.com.

    This option will have the same compilation semantics as VS 2003, and can make migration much easier.  I have a set of tutorials on the site that you can use to learn more about the system.  This tutorial specifically covers migrating existing VS 2003 apps to use this project option: http://webproject.scottgu.com/CSharp/Migration/Migration.aspx

    What I've usually found is that people can upgrade a complex VS 2003 project to it within about 20 minutes.

    Hope this helps,


    P.S. Note that the preview build isn't feature-complete, but is very stable. We are going to be updating it with a refresh build in a few weeks with more features, and will then finish it up entirely a few weeks after that (including an automated upgrade wizard).

    Monday, January 16, 2006 2:23 AM
  • User2032526919 posted

    What I've usually found is that people can upgrade a complex VS 2003 project to it within about 20 minutes.

    Now that we are on the subject... we did an upgrade for such application, e.g a quite complex VS2003 one on Friday, but we didn't  it to Web Application Project, but to the default web site model, just having the web project conversion wizard updated with the latest one (http://www.microsoft.com/downloads/details.aspx?FamilyId=7CECD652-FC04-4EF8-A28A-25C5006677D8&displaylang=en)

    It tooks 1,5 hours, which in my opinion was incredibly fast and succeeded conversion. we were prepared for days... so making it in 20 minutes is quite amazing. :-)

    Monday, January 16, 2006 3:33 AM
  • User-501215646 posted

    Fantastic, getting all this feedback from the experts :-) I haven't tried it out yet, but I will as soon as I get the time...

    Any of you know any good articles on other key considerations and best practices when converting from 1.1 to 2.0? The ones I have forund so far, are a bit to advanced for me, and I've found that even basic things need changes.

    Thanks in advance :-)



    Monday, January 16, 2006 6:13 AM
  • Monday, January 16, 2006 10:24 AM
  • User-501215646 posted
    Thanks, this should give me a kick in the right direction...

    Tuesday, January 17, 2006 2:04 PM