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. Communication Between asp.net files

Communication Between asp.net files

Scheduled Pinned Locked Moved ASP.NET
questioncsharpasp-net
11 Posts 5 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.
  • E eggie5

    I have 2 asp.net files: default.aspx.cs and test.aspx.cs How can I call methods from test.aspx.cs from default.aspx.cs? I can't seem to call methods from a different file unless it's in my appcode folder.

    /\ |_ E X E GG

    S Offline
    S Offline
    Sonia Gupta
    wrote on last edited by
    #2

    i think function calling is posible if class is placed in appcode folder.

    Sonia Gupta Soniagupta1@yahoo.co.in Yahoo messengerId-soniagupta1 Love is Friendship and Friendship is Love....

    I E 2 Replies Last reply
    0
    • S Sonia Gupta

      i think function calling is posible if class is placed in appcode folder.

      Sonia Gupta Soniagupta1@yahoo.co.in Yahoo messengerId-soniagupta1 Love is Friendship and Friendship is Love....

      I Offline
      I Offline
      Imran Khan Pathan
      wrote on last edited by
      #3

      Try this code Use this line where u want to call Function In .aspx page <%@ PreviousPageType VirtualPath="~/index.aspx" %> in .aspx.cs this.PreviousPage.Login(); //Make sure your method is public Best Regard Pathan -- modified at 0:54 Wednesday 1st August, 2007

      ---------------------------------------------------

      S 1 Reply Last reply
      0
      • S Sonia Gupta

        i think function calling is posible if class is placed in appcode folder.

        Sonia Gupta Soniagupta1@yahoo.co.in Yahoo messengerId-soniagupta1 Love is Friendship and Friendship is Love....

        E Offline
        E Offline
        eggie5
        wrote on last edited by
        #4

        The appcode folder is global to the whole application, then I loose isolation between debug and release code in my app.

        /\ |_ E X E GG

        1 Reply Last reply
        0
        • E eggie5

          I have 2 asp.net files: default.aspx.cs and test.aspx.cs How can I call methods from test.aspx.cs from default.aspx.cs? I can't seem to call methods from a different file unless it's in my appcode folder.

          /\ |_ E X E GG

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

          Someone else was asking this the other day. You can't. You just can't. test.aspx.cs does NOT exist when default.aspx.cs is running. The class instances are created as the pages are served. If you have stuff you want to be able to call from many pages, give them a common base class.

          Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

          E 1 Reply Last reply
          0
          • C Christian Graus

            Someone else was asking this the other day. You can't. You just can't. test.aspx.cs does NOT exist when default.aspx.cs is running. The class instances are created as the pages are served. If you have stuff you want to be able to call from many pages, give them a common base class.

            Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

            E Offline
            E Offline
            eggie5
            wrote on last edited by
            #6

            Ok, then that clears it up. So I guess my next solution would be to put the common code I need, into an app_code folder.

            /\ |_ E X E GG

            1 Reply Last reply
            0
            • I Imran Khan Pathan

              Try this code Use this line where u want to call Function In .aspx page <%@ PreviousPageType VirtualPath="~/index.aspx" %> in .aspx.cs this.PreviousPage.Login(); //Make sure your method is public Best Regard Pathan -- modified at 0:54 Wednesday 1st August, 2007

              ---------------------------------------------------

              S Offline
              S Offline
              Sonia Gupta
              wrote on last edited by
              #7

              imran i tried ur code i got the following exceptions Object reference not set to an instance of an object. at the following line this.PreviousPage.Login();

              Sonia Gupta Soniagupta1@yahoo.co.in Yahoo messengerId-soniagupta1 Love is Friendship and Friendship is Love....

              I 1 Reply Last reply
              0
              • S Sonia Gupta

                imran i tried ur code i got the following exceptions Object reference not set to an instance of an object. at the following line this.PreviousPage.Login();

                Sonia Gupta Soniagupta1@yahoo.co.in Yahoo messengerId-soniagupta1 Love is Friendship and Friendship is Love....

                I Offline
                I Offline
                Imran Khan Pathan
                wrote on last edited by
                #8

                Now try this take two page test1.aspx and test2.aspx Take LinkButton in test1.aspx LinkButton and write public method i.e public string Login() { return "Welcome"; } Now In test2.aspx <%@ PreviousPageType VirtualPath="~/test1.aspx" %> Call Method in page load event Response.Write(this.PreviousPage.Login()); Run test1.aspx and click on LinkButton Best Regard Pathan ---------------------------------------------------

                S N 2 Replies Last reply
                0
                • I Imran Khan Pathan

                  Now try this take two page test1.aspx and test2.aspx Take LinkButton in test1.aspx LinkButton and write public method i.e public string Login() { return "Welcome"; } Now In test2.aspx <%@ PreviousPageType VirtualPath="~/test1.aspx" %> Call Method in page load event Response.Write(this.PreviousPage.Login()); Run test1.aspx and click on LinkButton Best Regard Pathan ---------------------------------------------------

                  S Offline
                  S Offline
                  Sonia Gupta
                  wrote on last edited by
                  #9

                  imran, have u tested the code u r providing.

                  Sonia Gupta Soniagupta1@yahoo.co.in Yahoo messengerId-soniagupta1 Love is Friendship and Friendship is Love....

                  I 1 Reply Last reply
                  0
                  • S Sonia Gupta

                    imran, have u tested the code u r providing.

                    Sonia Gupta Soniagupta1@yahoo.co.in Yahoo messengerId-soniagupta1 Love is Friendship and Friendship is Love....

                    I Offline
                    I Offline
                    Imran Khan Pathan
                    wrote on last edited by
                    #10

                    Yes

                    ---------------------------------------------------

                    1 Reply Last reply
                    0
                    • I Imran Khan Pathan

                      Now try this take two page test1.aspx and test2.aspx Take LinkButton in test1.aspx LinkButton and write public method i.e public string Login() { return "Welcome"; } Now In test2.aspx <%@ PreviousPageType VirtualPath="~/test1.aspx" %> Call Method in page load event Response.Write(this.PreviousPage.Login()); Run test1.aspx and click on LinkButton Best Regard Pathan ---------------------------------------------------

                      N Offline
                      N Offline
                      Nand Kumar Das
                      wrote on last edited by
                      #11

                      well i have tested this code it really works great

                      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