Compile errors after converting to a Web Application Project from

Discussion in 'ASP .Net' started by Howard Pinsley, Nov 21, 2008.

  1. I'm trying to convert a Web Site to the Web Application project model and I'm
    running into compile errors that do not seem to be covered by the guidance I
    found at "Converting a Web Site Project to a Web Application Project".

    The issue is that standard ASP.NET controls that are embedded as child
    controls within the ContentTemplate of the Ajax Control Toolkit's
    TabContainer/TabPanel are no longer visible to the page (and result in
    compile errors). It appears that they can only be referenced with a call to
    FindControl whereas, when the project was a Web Site, they were directly
    accessible in the page's code behind file as properties.

    Unfortunately, we have a lot of webforms that utilize the TabContainer, and
    converting all the references to child controls from simple property refences
    to FindControl calls will be quite burdensome.

    While researching the problem I found a reference to a property called
    TemplateInstance that seemed promising, but I understand that this is
    applicable to control designers, not control users.

    I thought I'd add one other point. The problem is not specific to the Ajax
    Control Toolkit's TabContainer. Indeed, I have a FormView control, and all
    the child controls in the ItemTemplate are no longer recognized by the
    compiler as being properies of the Page and result in compile errors. I can't
    believe that I have to change all of these propery references to findcontrol
    calls throughout my forms just because I moved from a Web Site to a Web
    Application Project. :-(
     
    Howard Pinsley, Nov 21, 2008
    #1
    1. Advertising

  2. Howard Pinsley

    bruce barker Guest

    web applications are a bit of a hack. the codebehind are compiled by visual
    studio, the aspx by the aspnet_compiler. because the partial classes are in
    seperate dll's, there are more restrictions on code sharing (web site compile
    the aspx and the code behind into one dll, so all parial class features are
    available). to get around some of the restrictions, the ide generates those
    designer files, which allows type information to be shared between the
    partial classes (basically declaring server controls as protected global).

    so yes, you have to do the convert. there is a performance cost to using
    findcontrol, so you want to avoid this as much as possible.

    i have never seen an advantage to switch to web applications, but have
    converted web applications to web sites. (the main exception is MVC
    applications, but then you don't have codebehind files).

    -- bruce (sqlwork.com)


    "Howard Pinsley" wrote:

    > I'm trying to convert a Web Site to the Web Application project model and I'm
    > running into compile errors that do not seem to be covered by the guidance I
    > found at "Converting a Web Site Project to a Web Application Project".
    >
    > The issue is that standard ASP.NET controls that are embedded as child
    > controls within the ContentTemplate of the Ajax Control Toolkit's
    > TabContainer/TabPanel are no longer visible to the page (and result in
    > compile errors). It appears that they can only be referenced with a call to
    > FindControl whereas, when the project was a Web Site, they were directly
    > accessible in the page's code behind file as properties.
    >
    > Unfortunately, we have a lot of webforms that utilize the TabContainer, and
    > converting all the references to child controls from simple property refences
    > to FindControl calls will be quite burdensome.
    >
    > While researching the problem I found a reference to a property called
    > TemplateInstance that seemed promising, but I understand that this is
    > applicable to control designers, not control users.
    >
    > I thought I'd add one other point. The problem is not specific to the Ajax
    > Control Toolkit's TabContainer. Indeed, I have a FormView control, and all
    > the child controls in the ItemTemplate are no longer recognized by the
    > compiler as being properies of the Page and result in compile errors. I can't
    > believe that I have to change all of these propery references to findcontrol
    > calls throughout my forms just because I moved from a Web Site to a Web
    > Application Project. :-(
     
    bruce barker, Nov 22, 2008
    #2
    1. Advertising

  3. RE: Compile errors after converting to a Web Application Project f

    "bruce barker" wrote:

    > web applications are a bit of a hack. the codebehind are compiled by visual
    > studio, the aspx by the aspnet_compiler. because the partial classes are in
    > seperate dll's, there are more restrictions on code sharing (web site compile
    > the aspx and the code behind into one dll, so all parial class features are
    > available). to get around some of the restrictions, the ide generates those
    > designer files, which allows type information to be shared between the
    > partial classes (basically declaring server controls as protected global).
    >
    > so yes, you have to do the convert. there is a performance cost to using
    > findcontrol, so you want to avoid this as much as possible.
    >
    > i have never seen an advantage to switch to web applications, but have
    > converted web applications to web sites. (the main exception is MVC
    > applications, but then you don't have codebehind files).
    >
    > -- bruce (sqlwork.com)
    >


    Bruce:

    Thank you for your reply. I've been hacking at this for a while now and
    you're the first person to explain this. It's funny you bring up MVC. The
    whole reason for doing this excercise is to take a project that started as
    WebForms and move it to MVC. I want the freedom to do new stuff with MVC
    (because I happen to like that model), but leave the existing work (two
    developers, 3 months) in WebForms.

    I read an article by Scott Hanselman about the ability for WebForms and MVC
    to coexist in the same project. In order to create this hybrid, I created an
    empty MVC project and started copying in stuff from the WebForms project.
    When I ran into problems, (documents at StackOverflow
    http://stackoverflow.com/questions/297895/problem-mixing-webforms-into-aspnet-mvc-application),
    someone opined that I needed to FIRST convert the WebForms-based Web Site to
    a Web Applications project as an intermediate step to getting the WebForms
    into the MVC project. I guess because the Web Application model (i.e. using
    a project file) more closely aligns with the MVC project structure.

    Does this align with your understanding? Sounds like if I want to create
    this hybrid, I have no choice but to put FindControls all over the place (in
    all the WebForms that have been created by my two colleagues (and myself) to
    date in this project).

    Thanks again!
     
    Howard Pinsley, Nov 22, 2008
    #3
    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. Mark Goldin

    Errors, errors, errors

    Mark Goldin, Jan 17, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    965
    Mark Goldin
    Jan 17, 2004
  2. =?Utf-8?B?anJldHQ=?=
    Replies:
    1
    Views:
    919
    Laurent Bugnion
    Sep 26, 2006
  3. Nagaraj
    Replies:
    1
    Views:
    872
    Lionel B
    Mar 1, 2007
  4. John Dalberg
    Replies:
    1
    Views:
    519
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Mar 28, 2007
  5. ITistic
    Replies:
    2
    Views:
    431
    ITistic
    Aug 21, 2007
Loading...

Share This Page