Code behind not in separate file

Discussion in 'ASP .Net' started by Terry Olsen, Dec 1, 2006.

  1. Terry Olsen

    Terry Olsen Guest

    I didn't choose "code in separate file" when creating a web page. So I have
    to use the fully qualified object names because I can't figure out where, or
    even if i can, put the Imports statement. Can anyone shed some light on
    this? What are the limitations when you have the server-side code in the
    aspx file?
     
    Terry Olsen, Dec 1, 2006
    #1
    1. Advertising

  2. Terry Olsen

    Masudur Guest

    Terry Olsen wrote:
    > I didn't choose "code in separate file" when creating a web page. So I have
    > to use the fully qualified object names because I can't figure out where, or
    > even if i can, put the Imports statement. Can anyone shed some light on
    > this? What are the limitations when you have the server-side code in the
    > aspx file?


    Hi,

    When you are using server side codes in aspx page , you can still use
    the import statement but in a different way.

    just put the import statement below you page declaration

    <%@ Page Language="C#" %>
    <%@ Import Namespace="MyPackage.MyNameSpace" %>

    thats it...

    But its better to use code behind file.

    Code behind file is introduced to make your code more maintainable
    and separating the code logic from the page helps enforce the MVC
    pattern.

    Thanks
    Masudur
    kaz Software Ltd.
    www.kaz.com.bd
     
    Masudur, Dec 1, 2006
    #2
    1. Advertising

  3. Hi,

    Terry Olsen wrote:
    > I didn't choose "code in separate file" when creating a web page. So I have
    > to use the fully qualified object names because I can't figure out where, or
    > even if i can, put the Imports statement. Can anyone shed some light on
    > this? What are the limitations when you have the server-side code in the
    > aspx file?


    There are many disadvantages to having the code in the ASPX file. First,
    you don't have the clean separation between UI and code, then you must
    publish the uncompiled code to the server, and finally as you found out,
    linking to other libraries is more difficult.

    I strongly recommend you to use code-behind files.

    HTH,
    Laurent
    --
    Laurent Bugnion, GalaSoft
    Software engineering: http://www.galasoft-LB.ch
    PhotoAlbum: http://www.galasoft-LB.ch/pictures
    Support children in Calcutta: http://www.calcutta-espoir.ch
     
    Laurent Bugnion, Dec 1, 2006
    #3
    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:
    588
    Alphonse Giambrone
    Jun 28, 2003
  2. Pavan Apuroop

    Code behind file in separate folder

    Pavan Apuroop, Jun 24, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    1,970
    Juan T. Llibre
    Jun 24, 2005
  3. EvgueniB
    Replies:
    1
    Views:
    632
    Anthony Borla
    Dec 15, 2003
  4. Frank Fredstone
    Replies:
    1
    Views:
    442
    Jean-Francois Briere
    Jun 27, 2006
  5. John

    Non-code behind to code behind

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

Share This Page