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. Page Inheritance

Page Inheritance

Scheduled Pinned Locked Moved ASP.NET
oopquestion
5 Posts 4 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.
  • K Offline
    K Offline
    kirthikirthi
    wrote on last edited by
    #1

    Hi I writen a function in 1 Page i have to call that function in every page How can i call the function in every page OR some pages asdfasdfasdfasdfasdfasdfasdfasdfasdfasdf

    A _ I 3 Replies Last reply
    0
    • K kirthikirthi

      Hi I writen a function in 1 Page i have to call that function in every page How can i call the function in every page OR some pages asdfasdfasdfasdfasdfasdfasdfasdfasdfasdf

      A Offline
      A Offline
      Anish Gopi
      wrote on last edited by
      #2

      Hai, I will be better to keep the method in a seperate class file. Eg:

      classs Utilities
      {
      public static void doCommonJob()
      {
      }
      }

      or create a custom page class with this function implemnted. Then make all pages you need to call this fucntion inherit from this class eg:

      classs MyBasePage : Page
      {
      public void doCommonJob()
      {
      }
      }

      classs MyPage : MyBasePage{}

      1 Reply Last reply
      0
      • K kirthikirthi

        Hi I writen a function in 1 Page i have to call that function in every page How can i call the function in every page OR some pages asdfasdfasdfasdfasdfasdfasdfasdfasdfasdf

        _ Offline
        _ Offline
        _mubashir
        wrote on last edited by
        #3

        Hello.. Place the common function code in a class file and declare the function as STATIC. By this you can easily access that function by Class Name... like public class TestCls { Public static SomeFunc() {// some code} } ........................ Now to access it in any page you can use TestCls.SomeFunc(); i.e no need to create the object of that class. regards _mubashir

        I 1 Reply Last reply
        0
        • _ _mubashir

          Hello.. Place the common function code in a class file and declare the function as STATIC. By this you can easily access that function by Class Name... like public class TestCls { Public static SomeFunc() {// some code} } ........................ Now to access it in any page you can use TestCls.SomeFunc(); i.e no need to create the object of that class. regards _mubashir

          I Offline
          I Offline
          Ista
          wrote on last edited by
          #4

          doing this would require a sync lock because its not thread safe and would eventually blow up 1 line of code equals many bugs. So don't write any!!

          1 Reply Last reply
          0
          • K kirthikirthi

            Hi I writen a function in 1 Page i have to call that function in every page How can i call the function in every page OR some pages asdfasdfasdfasdfasdfasdfasdfasdfasdfasdf

            I Offline
            I Offline
            Ista
            wrote on last edited by
            #5

            public class MyDefautPage : Page { myMethod } then inherit from public class MyNewPage : MyDefaultPage 1 line of code equals many bugs. So don't write any!!

            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