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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Calling a web form as a class

Calling a web form as a class

Scheduled Pinned Locked Moved ASP.NET
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
    abdelhameed81
    wrote on last edited by
    #1

    hello all, i need to know if i can call the web form as if it is a class that i can inherite or take an object of it thanks in advance abdelhameed81

    P C 2 Replies Last reply
    0
    • A abdelhameed81

      hello all, i need to know if i can call the web form as if it is a class that i can inherite or take an object of it thanks in advance abdelhameed81

      P Offline
      P Offline
      pmarfleet
      wrote on last edited by
      #2

      abdelhameed81 wrote:

      i need to know if i can call the web form as if it is a class that i can inherite or take an object of it

      You could have a number of of web forms that inherit from the same code-behind class. I can't imagine why you would want to create an instance of a web form code-behind class on its own though. Maybe you can further clarify what you want to achieve.

      Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush

      A 1 Reply Last reply
      0
      • A abdelhameed81

        hello all, i need to know if i can call the web form as if it is a class that i can inherite or take an object of it thanks in advance abdelhameed81

        C Offline
        C Offline
        Colin Angus Mackay
        wrote on last edited by
        #3

        Your web form is a class already. You can inherit from it, create an instance of it (making an object of it) and so on. But, why would you want to create one outside of the context that ASP.NET creates it for you in the first place?

        Upcoming FREE developer events: * Developer Day Scotland Recent blog posts: * Mixins in C#3.0 My website | Blog

        A 1 Reply Last reply
        0
        • P pmarfleet

          abdelhameed81 wrote:

          i need to know if i can call the web form as if it is a class that i can inherite or take an object of it

          You could have a number of of web forms that inherit from the same code-behind class. I can't imagine why you would want to create an instance of a web form code-behind class on its own though. Maybe you can further clarify what you want to achieve.

          Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush

          A Offline
          A Offline
          abdelhameed81
          wrote on last edited by
          #4

          thanks for replying. The idea is that i need to access a control inside that form to make some modifications in that user control instead of creating many user controls with some minor changes. I hope that i made the idea clearer. Thanks

          P 1 Reply Last reply
          0
          • C Colin Angus Mackay

            Your web form is a class already. You can inherit from it, create an instance of it (making an object of it) and so on. But, why would you want to create one outside of the context that ASP.NET creates it for you in the first place?

            Upcoming FREE developer events: * Developer Day Scotland Recent blog posts: * Mixins in C#3.0 My website | Blog

            A Offline
            A Offline
            abdelhameed81
            wrote on last edited by
            #5

            thanks please refer to my reply on pmarfleet Br,

            1 Reply Last reply
            0
            • A abdelhameed81

              thanks for replying. The idea is that i need to access a control inside that form to make some modifications in that user control instead of creating many user controls with some minor changes. I hope that i made the idea clearer. Thanks

              P Offline
              P Offline
              pmarfleet
              wrote on last edited by
              #6

              This sounds like a horrible idea. I would strongly discourage it. What kind of minor changes are you talking about? If they are cosmetic changes, you could consider writing a templated user control where the presentation can be modified for each instance.

              Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush

              A 1 Reply Last reply
              0
              • P pmarfleet

                This sounds like a horrible idea. I would strongly discourage it. What kind of minor changes are you talking about? If they are cosmetic changes, you could consider writing a templated user control where the presentation can be modified for each instance.

                Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush

                A Offline
                A Offline
                abdelhameed81
                wrote on last edited by
                #7

                mmmm this sounds like a good idea, thanks for your support :)

                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