Results 1 to 5 of 5

Thread: difference between code-behind, and in code

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 1999
    Location
    Westfield, IN, USA
    Posts
    59

    difference between code-behind, and in code

    i've been looking at coding in the typical brackets in the webpages (ie. <% %>) compared to using the code-behind method. Sometimes i get different results, using the exact same code.

    Is there a difference in where you put it? I really like how the code-behind formats it for me, where in the HTML view, i have to format it... (perhaps i'm just lazy). Or am i just doing something incorrectly?

  2. #2
    Fanatic Member Patoooey's Avatar
    Join Date
    Aug 2001
    Location
    New Jersey, USA
    Posts
    774
    I place all code/html in one page because I don't have VS.Studio. CodeBehind is too much work without it. I've yet to run into any situation where I can't do something so it doesn't **really** matter where you place the code.

    There are differences in how you do some things. The context is different. Calls in the aspx page that work fine, fail in codebehind unless you change it slightly. Nothing major but it's there.

    IMHO, CodeBehind is for orgainization. It makes it easier to write/maintain your program if the 2 are seperate. Much cleaner **IF** you have VS.Studio. Makes it a tad annoying if you don't have it(have to combine samples, only so many copies of Notepad I can have open before I get confused, etc).

    Overall....if I had VS.Studio, I'd do it all with Codebehind. Most of the books/samples use it and it looks more professional.

    John

  3. #3
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    I concur with Patooey that the main advantage is organization. As it is easier to keep design in 1 file, and logic in another..

    although code behind is not really that hard without VS..
    Use textpad instead of notepad Patooey because it keeps seperate files tabulated so its easier to switch between what files you need.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  4. #4

    Thread Starter
    Member
    Join Date
    Sep 1999
    Location
    Westfield, IN, USA
    Posts
    59
    ok, then i'm going to have to find my example i was doing, and post it here to see exactly why it wouldn't work.

    i believe i made a sub() and tried calling it from another part of the document, and it would work in the .aspx page, but not in the code-behind.

    I would prefer the code-behind, since i can keep the coding out of the designer's view...

  5. #5

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width