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. UserControls in App_Code-directory

UserControls in App_Code-directory

Scheduled Pinned Locked Moved ASP.NET
9 Posts 2 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.
  • J Offline
    J Offline
    Johan Martensson
    wrote on last edited by
    #1

    I took over a project and found usercontrols in the App_Code-directory, now I was wondering, why put them in App_Code and not just anywhere else. The only reason I could find was if it was a base-class and I want other controls to inherit from it. But if it's just a control that let say shows a logo with some text, why would I put that control in App_Code

    http://johanmartensson.se - Home of MPEG4Watcher

    C 1 Reply Last reply
    0
    • J Johan Martensson

      I took over a project and found usercontrols in the App_Code-directory, now I was wondering, why put them in App_Code and not just anywhere else. The only reason I could find was if it was a base-class and I want other controls to inherit from it. But if it's just a control that let say shows a logo with some text, why would I put that control in App_Code

      http://johanmartensson.se - Home of MPEG4Watcher

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      If it's in app code, it must be a control entirely in code, no markup. That would then be where it belongs

      Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

      J 1 Reply Last reply
      0
      • C Christian Graus

        If it's in app code, it must be a control entirely in code, no markup. That would then be where it belongs

        Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

        J Offline
        J Offline
        Johan Martensson
        wrote on last edited by
        #3

        So as soon as I'm creating a control that uses hyperlink, textbox and so on, It should not be in App_Code. I found a UserControl with this method in it: public override void RenderControl(System.Web.UI.HtmlTextWriter writer) { writer.Write(" [" + this.Language[0] + "](\)|[" + this.Language[1] + "](\)|[" + this.Language[2] + "](\) "); } This feels wrong to me, I would have put it in a normal usercontrol outside App_code and used hyperlinks instead.

        http://johanmartensson.se - Home of MPEG4Watcher

        C 1 Reply Last reply
        0
        • J Johan Martensson

          So as soon as I'm creating a control that uses hyperlink, textbox and so on, It should not be in App_Code. I found a UserControl with this method in it: public override void RenderControl(System.Web.UI.HtmlTextWriter writer) { writer.Write(" [" + this.Language[0] + "](\)|[" + this.Language[1] + "](\)|[" + this.Language[2] + "](\) "); } This feels wrong to me, I would have put it in a normal usercontrol outside App_code and used hyperlinks instead.

          http://johanmartensson.se - Home of MPEG4Watcher

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          If it's code, not a control with an ascx, the App_Code is the only place for it unless you put it in a dll. Otherwise, it's not going to be compiled. If the person who worked on it before made good choices in what to use, is a different question, that much is true.

          Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

          J 1 Reply Last reply
          0
          • C Christian Graus

            If it's code, not a control with an ascx, the App_Code is the only place for it unless you put it in a dll. Otherwise, it's not going to be compiled. If the person who worked on it before made good choices in what to use, is a different question, that much is true.

            Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

            J Offline
            J Offline
            Johan Martensson
            wrote on last edited by
            #5

            So I should only create a usercontrol in App_Code if I have a good reason for it? I just can't figure out what that good reason is...

            http://johanmartensson.se - Home of MPEG4Watcher

            C 1 Reply Last reply
            0
            • J Johan Martensson

              So I should only create a usercontrol in App_Code if I have a good reason for it? I just can't figure out what that good reason is...

              http://johanmartensson.se - Home of MPEG4Watcher

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #6

              I would tend to put them in a dll for reuse, if I wrote any,

              Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

              J 1 Reply Last reply
              0
              • C Christian Graus

                I would tend to put them in a dll for reuse, if I wrote any,

                Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

                J Offline
                J Offline
                Johan Martensson
                wrote on last edited by
                #7

                Absolutely, I would do that to if I were to reuse them. Could the be any benefits like loading-speed or something if I put the usercontrols in app_code rather than outside?

                http://johanmartensson.se - Home of MPEG4Watcher

                C 1 Reply Last reply
                0
                • J Johan Martensson

                  Absolutely, I would do that to if I were to reuse them. Could the be any benefits like loading-speed or something if I put the usercontrols in app_code rather than outside?

                  http://johanmartensson.se - Home of MPEG4Watcher

                  C Offline
                  C Offline
                  Christian Graus
                  wrote on last edited by
                  #8

                  None I can think of. They only get loaded the first time a page gets accessed, then they live in server memory

                  Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

                  J 1 Reply Last reply
                  0
                  • C Christian Graus

                    None I can think of. They only get loaded the first time a page gets accessed, then they live in server memory

                    Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

                    J Offline
                    J Offline
                    Johan Martensson
                    wrote on last edited by
                    #9

                    Yeah, that's what I thought, I just keep the usercontrols out of app_code until I find a good reason to to otherwise. Thanks Christian...

                    http://johanmartensson.se - Home of MPEG4Watcher

                    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