Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Accessing code-behind file in ASP.NET 2.0

Accessing code-behind file in ASP.NET 2.0

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netvisual-studiocomcollaboration
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Alex Getman
    wrote on last edited by
    #1

    Hi all! Does there exists some way to access VS.NET 2005 generated code-behind files in Web Site Project? I found how to navigate to the designer page in WinFroms Applicaiton, but is it possible to view and edit designer-generated cs files for Web Applications? xedom developers team personal web page

    T M 2 Replies Last reply
    0
    • A Alex Getman

      Hi all! Does there exists some way to access VS.NET 2005 generated code-behind files in Web Site Project? I found how to navigate to the designer page in WinFroms Applicaiton, but is it possible to view and edit designer-generated cs files for Web Applications? xedom developers team personal web page

      T Offline
      T Offline
      ToddHileHoffer
      wrote on last edited by
      #2

      I don't think so. It's stored in a separate file because they are partial classes. "People who never make mistakes, never do anything." My Blog

      A 1 Reply Last reply
      0
      • T ToddHileHoffer

        I don't think so. It's stored in a separate file because they are partial classes. "People who never make mistakes, never do anything." My Blog

        A Offline
        A Offline
        Alex Getman
        wrote on last edited by
        #3

        >stored in a separate file because they are partial classes. Yes, they do. But I can easy access second (design generated) part of partial class in WinForms project. Once, I've seen some blog post where it was desribed how to access code-behind in VS.NET 2005 but I think it was about VS.NEt 2005 Beta or Community Preview... xedom developers team personal web page

        T 1 Reply Last reply
        0
        • A Alex Getman

          >stored in a separate file because they are partial classes. Yes, they do. But I can easy access second (design generated) part of partial class in WinForms project. Once, I've seen some blog post where it was desribed how to access code-behind in VS.NET 2005 but I think it was about VS.NEt 2005 Beta or Community Preview... xedom developers team personal web page

          T Offline
          T Offline
          ToddHileHoffer
          wrote on last edited by
          #4

          I have been able to find the windows one as well but not the web. I know they are compiled to C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\ but I don't where the C# or VB.Net is. I'm interested to know as well. "People who never make mistakes, never do anything." My Blog

          1 Reply Last reply
          0
          • A Alex Getman

            Hi all! Does there exists some way to access VS.NET 2005 generated code-behind files in Web Site Project? I found how to navigate to the designer page in WinFroms Applicaiton, but is it possible to view and edit designer-generated cs files for Web Applications? xedom developers team personal web page

            M Offline
            M Offline
            minhpc_bk
            wrote on last edited by
            #5

            Hi there, As you already know that the ASP.NET uses the similar way of the windows app model to seperate the generated code in a seperate file. However, the second part of the code-behind class is generated when the web site is compiled. Basically, when you work on a web page, there are two files ending with *.ccu and *.compiled generated in the temp folder:

            C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\

            The code compile unit (ccu) file contains info about the web page such as the controls declared in the page aspx ..., and thanks to this file you can easily access these controls in code-behind without having to declare them like you did in the ASP.NET 1.x. When you compile the application, the ASP.NET will use this file and generate another part of the code-behind class and add it to a source file .cs ( assume the compilation in debug mode) that you can find in the temp folder, it's not in the same folder as the code-behind file. And this file simply contains the declaration for the web controls declared in the web page .aspx, so I'm curious why you want to access the generated file.

            A 1 Reply Last reply
            0
            • M minhpc_bk

              Hi there, As you already know that the ASP.NET uses the similar way of the windows app model to seperate the generated code in a seperate file. However, the second part of the code-behind class is generated when the web site is compiled. Basically, when you work on a web page, there are two files ending with *.ccu and *.compiled generated in the temp folder:

              C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\

              The code compile unit (ccu) file contains info about the web page such as the controls declared in the page aspx ..., and thanks to this file you can easily access these controls in code-behind without having to declare them like you did in the ASP.NET 1.x. When you compile the application, the ASP.NET will use this file and generate another part of the code-behind class and add it to a source file .cs ( assume the compilation in debug mode) that you can find in the temp folder, it's not in the same folder as the code-behind file. And this file simply contains the declaration for the web controls declared in the web page .aspx, so I'm curious why you want to access the generated file.

              A Offline
              A Offline
              Alex Getman
              wrote on last edited by
              #6

              >I'm curious why you want to access the generated file. Well, somtimes it's necessary ;) For example - when you need to fix some wrong generated code with EventHandler, also being able to edit generated file is importrant when you are migrating from ASP.NET 1.1 to 2.0 and not all code converted as you want. Anyway I think that separating class into multiple files maybe a good idea, but disabling access to code generated part - it's a very disputable descision of VS.NET 2005 team. We are developers, not users, and developers should have access to any fetures of the platform. xedom developers team personal web page

              M 1 Reply Last reply
              0
              • A Alex Getman

                >I'm curious why you want to access the generated file. Well, somtimes it's necessary ;) For example - when you need to fix some wrong generated code with EventHandler, also being able to edit generated file is importrant when you are migrating from ASP.NET 1.1 to 2.0 and not all code converted as you want. Anyway I think that separating class into multiple files maybe a good idea, but disabling access to code generated part - it's a very disputable descision of VS.NET 2005 team. We are developers, not users, and developers should have access to any fetures of the platform. xedom developers team personal web page

                M Offline
                M Offline
                minhpc_bk
                wrote on last edited by
                #7

                I guess that you used to have problems with the generated event handlers in VS 2003, me too :-D! As you already know that by default VS 2003 automatically generates the event handler in the code-behind class, however this thing is changed in VS 2005 since VS 2005 uses the inline code as the default model. You probably know that VS 2005 by default registers the event handler in the control declaration in the web page .aspx, not in code-behind. When we migrate a web project from VS 2003 to VS 2005, VS 2005 basically will remove the code to regsiter the event handler from code-behind to inline code. There is one exception for the event of the Page instance since it uses the form of the Page_EventName to register the event handler for Page's events. So if you have any problem with event handler from the migration, you may need to check the content file .aspx, anyway I agree with you that as sometimes the generated code may have problems, and we want to change it in the way we want, for example when the name of the partial class happens to be identical to a class defined in the .Net framework, and it does not throw any exception until we publish the web site and run it.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups