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. Advise on how to reuse code behind in asp.net VB pages

Advise on how to reuse code behind in asp.net VB pages

Scheduled Pinned Locked Moved ASP.NET
tutorialcsharpasp-netwinformshelp
6 Posts 3 Posters 17 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.
  • M Offline
    M Offline
    Member 8758302
    wrote on last edited by
    #1

    Hallo I have about 100 asp.net forms. I have a master page and many pages that refer to the master. The .aspx pages differ, but the .aspx.vb codebehind of all is essentially identical. The .aspx_vb has some parameter declarations and constants at the top, but the remainder of the .aspx_vb is identical generalised code - handling events like page_init, page_load etc. Obviously this is inefficient to maintain. Can someone offer advice of what techniques I should investigate to be able to centralise the common code into one code base and maintain it once. I have written extensions to existing controls previously - for example I have written extensions that inherit GridView and DropDownList. I also use User Controls extensively. Can someone point me to examples or articles to assist me solve this problem? thanks, Grant

    A L 2 Replies Last reply
    0
    • M Member 8758302

      Hallo I have about 100 asp.net forms. I have a master page and many pages that refer to the master. The .aspx pages differ, but the .aspx.vb codebehind of all is essentially identical. The .aspx_vb has some parameter declarations and constants at the top, but the remainder of the .aspx_vb is identical generalised code - handling events like page_init, page_load etc. Obviously this is inefficient to maintain. Can someone offer advice of what techniques I should investigate to be able to centralise the common code into one code base and maintain it once. I have written extensions to existing controls previously - for example I have written extensions that inherit GridView and DropDownList. I also use User Controls extensively. Can someone point me to examples or articles to assist me solve this problem? thanks, Grant

      A Offline
      A Offline
      Andre Oosthuizen
      wrote on last edited by
      #2

      You can use Classes that are essential in object-oriented programming. These will have functions that you can call to in any of your pages. I found numerous tutorials by searching writing and using classes in aspx[^]

      M 1 Reply Last reply
      0
      • M Member 8758302

        Hallo I have about 100 asp.net forms. I have a master page and many pages that refer to the master. The .aspx pages differ, but the .aspx.vb codebehind of all is essentially identical. The .aspx_vb has some parameter declarations and constants at the top, but the remainder of the .aspx_vb is identical generalised code - handling events like page_init, page_load etc. Obviously this is inefficient to maintain. Can someone offer advice of what techniques I should investigate to be able to centralise the common code into one code base and maintain it once. I have written extensions to existing controls previously - for example I have written extensions that inherit GridView and DropDownList. I also use User Controls extensively. Can someone point me to examples or articles to assist me solve this problem? thanks, Grant

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        The "easiest" way (IMO) to get some reuse is to identify methods that can be made static; with ease; i.e. don't have dependencies that can't be easily made into "parms". Those can be put in a static class / dll and shared that way. I have a lot of "builders" and "adapters" in that category.

        "Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I

        M 1 Reply Last reply
        0
        • A Andre Oosthuizen

          You can use Classes that are essential in object-oriented programming. These will have functions that you can call to in any of your pages. I found numerous tutorials by searching writing and using classes in aspx[^]

          M Offline
          M Offline
          Member 8758302
          wrote on last edited by
          #4

          Thanks Andre

          A 1 Reply Last reply
          0
          • L Lost User

            The "easiest" way (IMO) to get some reuse is to identify methods that can be made static; with ease; i.e. don't have dependencies that can't be easily made into "parms". Those can be put in a static class / dll and shared that way. I have a lot of "builders" and "adapters" in that category.

            "Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I

            M Offline
            M Offline
            Member 8758302
            wrote on last edited by
            #5

            Thanks Gerry. Helpful to know that there is no silver bullet. Based on this advice I'm isolating some functions out, and also building a class that inherits from the base.

            1 Reply Last reply
            0
            • M Member 8758302

              Thanks Andre

              A Offline
              A Offline
              Andre Oosthuizen
              wrote on last edited by
              #6

              You're welcome.

              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