Re: Call a function from another page

Discussion in 'ASP .Net' started by Gregory A. Beamer, Sep 30, 2009.

  1. "aspfun via DotNetMonster.com" <u53138@uwe> wrote in
    news:9ce55c99c84d4@uwe:

    > I have two aspx pages: A.aspx and B.aspx. They are in partial class A
    > and B. Under Partial Class A, there is a function called it as
    > <Protected Function GetID() as string>.
    > How to call this function from B.aspx?
    > I knew we can create a class file and copy this function into it and
    > call it from this class. I just want learn another way to do it.



    Technically, you can use a page class in this manner. You simply need to
    have the correct namespace and instantiate the class. The issue is you
    end up having to make sure you have neutered any events that might fire.
    It will likely be a very time consuming effort and go against the grain.
    the result will be you will have learned how to conquer something, but
    it is a hill that does not need to be conquered. But if you feel the
    need to conquer that hill, that is your business, not mine.

    On the other hand, you can refactor the logical bits into a class and
    run it from both places. This will take less than 5 minutes to
    accomplish. But you will not have climbed THAT hill.

    If it were me, I would move the application code into class libraries
    and use the ASP.NET app as a UI "skin" rather than have it contain
    application code. The learning effort would take about as long as using
    a page as a class, but would yield a much better application that is
    flexible enough to take on different UI types.

    So you choice is either learn how to build tiered applications or how to
    climb hills. ;-)

    Peace and Grace,


    --
    Gregory A. Beamer
    MVP; MCP: +I, SE, SD, DBA

    Twitter: @gbworld
    Blog: http://gregorybeamer.spaces.live.com

    *******************************************
    | Think outside the box! |
    *******************************************
    Gregory A. Beamer, Sep 30, 2009
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sandeep Chikkerur
    Replies:
    1
    Views:
    711
    Jack Klein
    Nov 18, 2003
  2. grbgooglefan
    Replies:
    2
    Views:
    410
    Pascal Bourguignon
    Jan 30, 2008
  3. grbgooglefan
    Replies:
    4
    Views:
    430
    Kenny McCormack
    Jan 30, 2008
  4. grbgooglefan
    Replies:
    0
    Views:
    384
    grbgooglefan
    Jan 30, 2008
  5. Randell D.
    Replies:
    38
    Views:
    285
    askMe
    Jul 19, 2005
Loading...

Share This Page