Multiple Code Behind Pages

Discussion in 'ASP .Net' started by Steven K, Aug 17, 2004.

  1. Steven K

    Steven K Guest

    Hello,

    Can a Code Behind Page call another page? I have 4 aspx.vb pages that have
    a portion of the code that is common. Every time I need to make a change, I
    have to make that change in all 4 files. Can the common code be moved to
    it's own page? If so, How would I reference it?

    Any advice would be appreciated.

    --
    Thanks in advance,

    Steven
    Steven K, Aug 17, 2004
    #1
    1. Advertising

  2. Steven K

    Curt_C [MVP] Guest

    Use inheritance.
    Have one page that has all the shared info, functions, etc. Then have the
    other pages inherit from that instead of System.Web.Page.


    --
    Curt Christianson
    Owner/Lead Developer, DF-Software
    Site: http://www.Darkfalz.com
    Blog: http://blog.Darkfalz.com


    "Steven K" <> wrote in message
    news:...
    > Hello,
    >
    > Can a Code Behind Page call another page? I have 4 aspx.vb pages that
    > have
    > a portion of the code that is common. Every time I need to make a change,
    > I
    > have to make that change in all 4 files. Can the common code be moved to
    > it's own page? If so, How would I reference it?
    >
    > Any advice would be appreciated.
    >
    > --
    > Thanks in advance,
    >
    > Steven
    >
    >
    Curt_C [MVP], Aug 17, 2004
    #2
    1. Advertising

  3. Steven K

    Mythran Guest

    "Steven K" <> wrote in message
    news:...
    > Hello,
    >
    > Can a Code Behind Page call another page? I have 4 aspx.vb pages that have
    > a portion of the code that is common. Every time I need to make a change, I
    > have to make that change in all 4 files. Can the common code be moved to
    > it's own page? If so, How would I reference it?
    >
    > Any advice would be appreciated.
    >
    > --
    > Thanks in advance,
    >
    > Steven
    >
    >


    Check out the user controls (in-project user controls.) They help tremendously
    with keeping code from being duplicated :)

    Add->Web User Control

    Hope this helps.

    Mythran
    Mythran, Aug 17, 2004
    #3
  4. Steven K

    Colin Young Guest

    In addition to the 2 excellent suggestions from Curt_C and Mythran, you
    could also put the code into a shared library (DLL) and reference that in
    the 4 pages that need it. The choice of method would be the one that is the
    most natural fit to your particular code requirements.

    Colin

    "Steven K" <> wrote in message
    news:...
    > Hello,
    >
    > Can a Code Behind Page call another page? I have 4 aspx.vb pages that

    have
    > a portion of the code that is common. Every time I need to make a change,

    I
    > have to make that change in all 4 files. Can the common code be moved to
    > it's own page? If so, How would I reference it?
    >
    > Any advice would be appreciated.
    >
    > --
    > Thanks in advance,
    >
    > Steven
    >
    >
    Colin Young, Aug 18, 2004
    #4
  5. Steven K

    Mythran Guest

    In that case, might as well just use a Module or Class file inside the single
    project if there are only a few routines. If it is larger in scope, then yeah,
    put into a shared library project under the same solution :)

    Mythran

    "Colin Young" <> wrote in message
    news:%...
    > In addition to the 2 excellent suggestions from Curt_C and Mythran, you
    > could also put the code into a shared library (DLL) and reference that in
    > the 4 pages that need it. The choice of method would be the one that is the
    > most natural fit to your particular code requirements.
    >
    > Colin
    >
    > "Steven K" <> wrote in message
    > news:...
    > > Hello,
    > >
    > > Can a Code Behind Page call another page? I have 4 aspx.vb pages that

    > have
    > > a portion of the code that is common. Every time I need to make a change,

    > I
    > > have to make that change in all 4 files. Can the common code be moved to
    > > it's own page? If so, How would I reference it?
    > >
    > > Any advice would be appreciated.
    > >
    > > --
    > > Thanks in advance,
    > >
    > > Steven
    > >
    > >

    >
    >
    Mythran, Aug 18, 2004
    #5
  6. Steven K

    Colin Young Guest

    So now we have four solutions. Thanks. I was trying to think of the word
    module or class this morning but my brain didn't want to work.

    Colin

    "Mythran" <> wrote in message
    news:...
    > In that case, might as well just use a Module or Class file inside the

    single
    > project if there are only a few routines. If it is larger in scope, then

    yeah,
    > put into a shared library project under the same solution :)
    >
    > Mythran
    >
    > "Colin Young" <> wrote in message
    > news:%...
    > > In addition to the 2 excellent suggestions from Curt_C and Mythran, you
    > > could also put the code into a shared library (DLL) and reference that

    in
    > > the 4 pages that need it. The choice of method would be the one that is

    the
    > > most natural fit to your particular code requirements.
    > >
    > > Colin
    > >
    > > "Steven K" <> wrote in message
    > > news:...
    > > > Hello,
    > > >
    > > > Can a Code Behind Page call another page? I have 4 aspx.vb pages that

    > > have
    > > > a portion of the code that is common. Every time I need to make a

    change,
    > > I
    > > > have to make that change in all 4 files. Can the common code be moved

    to
    > > > it's own page? If so, How would I reference it?
    > > >
    > > > Any advice would be appreciated.
    > > >
    > > > --
    > > > Thanks in advance,
    > > >
    > > > Steven
    > > >
    > > >

    > >
    > >

    >
    >
    Colin Young, Aug 18, 2004
    #6
    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. Ben Miller [msft]

    Re: Code Behind vs. no code behind: error

    Ben Miller [msft], Jun 27, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    579
    Alphonse Giambrone
    Jun 28, 2003
  2. =?Utf-8?B?Q3VydF9DIFtNVlBd?=

    RE: One code behind file and multiple ASPX pages?

    =?Utf-8?B?Q3VydF9DIFtNVlBd?=, Sep 7, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    437
    =?Utf-8?B?Q3VydF9DIFtNVlBd?=
    Sep 7, 2005
  3. =?Utf-8?B?TWU=?=

    One code behind file and multiple ASPX pages?

    =?Utf-8?B?TWU=?=, Sep 7, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    929
    Craig Deelsnyder
    Sep 7, 2005
  4. LiveCycle
    Replies:
    1
    Views:
    422
    Cowboy \(Gregory A. Beamer\)
    Nov 21, 2006
  5. John

    Non-code behind to code behind

    John, Feb 19, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    478
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Feb 19, 2007
Loading...

Share This Page