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. How to call a method in another .aspx file

How to call a method in another .aspx file

Scheduled Pinned Locked Moved ASP.NET
helptutorialquestion
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.
  • R Offline
    R Offline
    r_jaz
    wrote on last edited by
    #1

    Hi every one, I need to call a method resides in another .aspx file from another .aspx file (all in the code behind).. I tried making it public and static but still I can't access it, I can solve my problem if I could make the second page to post back when the first one do post back.. Any suggestions?? Thank You very much

    _ 1 Reply Last reply
    0
    • R r_jaz

      Hi every one, I need to call a method resides in another .aspx file from another .aspx file (all in the code behind).. I tried making it public and static but still I can't access it, I can solve my problem if I could make the second page to post back when the first one do post back.. Any suggestions?? Thank You very much

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

      You need to place your function (which you want to call in more than one pages) in a separate class, then make an instance of that class in your page and call that function. Simple Object Oriented Programming Mubashir

      Every job is a self portrait of the person who did it.

      F R 2 Replies Last reply
      0
      • _ _mubashir

        You need to place your function (which you want to call in more than one pages) in a separate class, then make an instance of that class in your page and call that function. Simple Object Oriented Programming Mubashir

        Every job is a self portrait of the person who did it.

        F Offline
        F Offline
        faiqshah
        wrote on last edited by
        #3

        mubashir is right You need to Crerat a separate class inside the class create a satic Method e.g Public static void MyFunction() { //some code } the function can be then call in many pages Note: The class must be of public scope

        1 Reply Last reply
        0
        • _ _mubashir

          You need to place your function (which you want to call in more than one pages) in a separate class, then make an instance of that class in your page and call that function. Simple Object Oriented Programming Mubashir

          Every job is a self portrait of the person who did it.

          R Offline
          R Offline
          r_jaz
          wrote on last edited by
          #4

          I can't do that bcus I wanna call "Page_Load" function of that page!!

          M 1 Reply Last reply
          0
          • R r_jaz

            I can't do that bcus I wanna call "Page_Load" function of that page!!

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

            What I did one time was create a interface with a execute method. Then add the interface to your page and then place a call to the Page_Load in the execute method. Then where you want to use is create a instance of the page and use the execute method. I hope this is usefull.

            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