Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > What's the difference/advantages between code behind and code inside?

Reply
Thread Tools

What's the difference/advantages between code behind and code inside?

 
 
Alan Silver
Guest
Posts: n/a
 
      01-27-2005
Hello,

Newbie here, so please forgive what is probably a basic question ...

I see a lot of discussion about "code behind", which if I have
understood correctly, means that the script code goes in a separate file
from the HTML. Apart from the obvious advantage if you have a separate
designer and programmer, are there any other advantages to code behind?

Most of the stuff I've seen so far uses code inside, but that's probably
because I'm still reading introductions and tutorials. It looks sensible
to me, as all the code is in one file (I can't afford to employ a
designer!!), albeit conveniently separated into sections.

So, any advantage of code behind? Thanks in advance for all and any
(helpful) responses.

--
Alan Silver
(anything added below this line is nothing to do with me)
 
Reply With Quote
 
 
 
 
Murray Jack
Guest
Posts: n/a
 
      01-27-2005
According to reports ive read there is no difference between the 2 in terms
of performance

I personally refer to use code behind as its more like the VB editors im
used to but i guess its up to you

Hope this helps




"Alan Silver" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello,
>
> Newbie here, so please forgive what is probably a basic question ...
>
> I see a lot of discussion about "code behind", which if I have understood
> correctly, means that the script code goes in a separate file from the
> HTML. Apart from the obvious advantage if you have a separate designer and
> programmer, are there any other advantages to code behind?
>
> Most of the stuff I've seen so far uses code inside, but that's probably
> because I'm still reading introductions and tutorials. It looks sensible
> to me, as all the code is in one file (I can't afford to employ a
> designer!!), albeit conveniently separated into sections.
>
> So, any advantage of code behind? Thanks in advance for all and any
> (helpful) responses.
>
> --
> Alan Silver
> (anything added below this line is nothing to do with me)



 
Reply With Quote
 
 
 
 
Eliyahu Goldin
Guest
Posts: n/a
 
      01-27-2005
In-page script can be changed on the site without re-deploying the whole
application.

Code behind lets you write program modules in a regular professional way.

Eliyahu

"Alan Silver" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello,
>
> Newbie here, so please forgive what is probably a basic question ...
>
> I see a lot of discussion about "code behind", which if I have
> understood correctly, means that the script code goes in a separate file
> from the HTML. Apart from the obvious advantage if you have a separate
> designer and programmer, are there any other advantages to code behind?
>
> Most of the stuff I've seen so far uses code inside, but that's probably
> because I'm still reading introductions and tutorials. It looks sensible
> to me, as all the code is in one file (I can't afford to employ a
> designer!!), albeit conveniently separated into sections.
>
> So, any advantage of code behind? Thanks in advance for all and any
> (helpful) responses.
>
> --
> Alan Silver
> (anything added below this line is nothing to do with me)



 
Reply With Quote
 
Curt_C [MVP]
Guest
Posts: n/a
 
      01-27-2005
ease of reading is enough for me....

FYI, in the new VS you should be able to "push a button" and switch your
model from code-behind to in-line or back again.

--
Curt Christianson
Site & Scripts: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com


"Alan Silver" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello,
>
> Newbie here, so please forgive what is probably a basic question ...
>
> I see a lot of discussion about "code behind", which if I have understood
> correctly, means that the script code goes in a separate file from the
> HTML. Apart from the obvious advantage if you have a separate designer and
> programmer, are there any other advantages to code behind?
>
> Most of the stuff I've seen so far uses code inside, but that's probably
> because I'm still reading introductions and tutorials. It looks sensible
> to me, as all the code is in one file (I can't afford to employ a
> designer!!), albeit conveniently separated into sections.
>
> So, any advantage of code behind? Thanks in advance for all and any
> (helpful) responses.
>
> --
> Alan Silver
> (anything added below this line is nothing to do with me)



 
Reply With Quote
 
Curt_C [MVP]
Guest
Posts: n/a
 
      01-27-2005
"Eliyahu Goldin" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> In-page script can be changed on the site without re-deploying the whole
> application.
>


fyi, so can code-behind with the right compile flags

--
Curt Christianson
Site & Scripts: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com


 
Reply With Quote
 
Eliyahu Goldin
Guest
Posts: n/a
 
      01-27-2005
But you don't usually deploy code-behind.

Eliyahu

"Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
news:%(E-Mail Removed)...
> "Eliyahu Goldin" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > In-page script can be changed on the site without re-deploying the whole
> > application.
> >

>
> fyi, so can code-behind with the right compile flags
>
> --
> Curt Christianson
> Site & Scripts: http://www.Darkfalz.com
> Blog: http://blog.Darkfalz.com
>
>



 
Reply With Quote
 
Alan Silver
Guest
Posts: n/a
 
      01-27-2005
>In-page script can be changed on the site without re-deploying the whole
>application.


Pardon my (admitted) ignorance, but why does code-behind require you to
redeploy the whole application? Maybe I'm just not sure what happens to
code-behind code when it gets compiled, I just assumed that either way
it went into a similar file.

>Code behind lets you write program modules in a regular professional way.


What does that mean? Surely professional programming is down to the
programmer getting it right, not a choice of where to place the code.
Please explain what you mean by this.

Thanks for the reply.

>Eliyahu


Nice name, I have a son with that name

>"Alan Silver" <(E-Mail Removed)> wrote in message
>news:(E-Mail Removed)...
>> Hello,
>>
>> Newbie here, so please forgive what is probably a basic question ...
>>
>> I see a lot of discussion about "code behind", which if I have
>> understood correctly, means that the script code goes in a separate file
>> from the HTML. Apart from the obvious advantage if you have a separate
>> designer and programmer, are there any other advantages to code behind?
>>
>> Most of the stuff I've seen so far uses code inside, but that's probably
>> because I'm still reading introductions and tutorials. It looks sensible
>> to me, as all the code is in one file (I can't afford to employ a
>> designer!!), albeit conveniently separated into sections.
>>
>> So, any advantage of code behind? Thanks in advance for all and any
>> (helpful) responses.
>>
>> --
>> Alan Silver
>> (anything added below this line is nothing to do with me)

>
>


--
Alan Silver
(anything added below this line is nothing to do with me)
 
Reply With Quote
 
Kevin Spencer
Guest
Posts: n/a
 
      01-27-2005
Separation of code and content.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

"Alan Silver" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello,
>
> Newbie here, so please forgive what is probably a basic question ...
>
> I see a lot of discussion about "code behind", which if I have understood
> correctly, means that the script code goes in a separate file from the
> HTML. Apart from the obvious advantage if you have a separate designer and
> programmer, are there any other advantages to code behind?
>
> Most of the stuff I've seen so far uses code inside, but that's probably
> because I'm still reading introductions and tutorials. It looks sensible
> to me, as all the code is in one file (I can't afford to employ a
> designer!!), albeit conveniently separated into sections.
>
> So, any advantage of code behind? Thanks in advance for all and any
> (helpful) responses.
>
> --
> Alan Silver
> (anything added below this line is nothing to do with me)



 
Reply With Quote
 
=?windows-1252?Q?Anders_Nor=E5s?=
Guest
Posts: n/a
 
      01-27-2005
Alan Silver wrote:
> So, any advantage of code behind? Thanks in advance for all and any
> (helpful) responses.

Codebehind is code that a web form, user control or web service uses
which is not located in the ASPX file. The design process of separating
code from the ASPX markup has many advantages. Most importantly; it
allows web designers to work with the HTML without messing up the
application code. Visual Studio .NET has almost no support for coding
within an ASPX page using <script runat="server> in line code, so the
codebehind model is the most widely used amongst ASP.NET developers.
Visual Studio .NET uses the codebehind attribute by default. This
attribute is completely ignored by the ASP.NET runtime. It is there to
enable Visual Studio .NET to associate ASPX files with their codebehind
files during development.

Visual Studio .NET compiles all codebehind classes to a single assembly
which is placed in the web application's "bin" folder when you build the
project. Therefore there is no need to deploy the *.aspx.cs or *.aspx.vb
files. Deploying the application code in a compiled assembly helps
protect intellectual property, because you don't have to make the source
code available.
You can configure ASP.NET to JIT compile the codebehind files, removing
the need for precompiled assemblies.

In line code can be a the right choice if your application is hosted by
a third party, where it is difficult to deploy compiled code to the
server or where you want to take advantage of JIT compilation of the
application code without having to tweak ASP.NET settings.

In ASP.NET 2.0 you'll get dynamical compilation no matter if you’re
putting your code into the ASPX file or in a codebehind file. In
addition you'll be able to deploy your code in compiled form without
sourcecode, even if you decide to write your code in line the ASPX file.

Personally I prefer to use codebehind in "real" projects and in line
code for short examples.

Anders Norås
http://dotnetjunkies.com/weblog/anoras/
 
Reply With Quote
 
Curt_C [MVP]
Guest
Posts: n/a
 
      01-27-2005
but you could... if you wanted that model, thats all I was saying :}

--
Curt Christianson
Site & Scripts: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com


"Eliyahu Goldin" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> But you don't usually deploy code-behind.
>
> Eliyahu
>
> "Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
> news:%(E-Mail Removed)...
>> "Eliyahu Goldin" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> > In-page script can be changed on the site without re-deploying the
>> > whole
>> > application.
>> >

>>
>> fyi, so can code-behind with the right compile flags
>>
>> --
>> Curt Christianson
>> Site & Scripts: http://www.Darkfalz.com
>> Blog: http://blog.Darkfalz.com
>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Non-code behind to code behind John ASP .Net 2 02-19-2007 07:08 PM
Controls lost their connection between Code behind and .aspx page Elmo Watson ASP .Net 2 09-15-2006 02:23 PM
what is the difference between code inside a <script> tag and code in the code-behind file? keithb ASP .Net 1 03-29-2006 01:00 AM
Code-Behind Pain in the Behind! Daniel Manes ASP .Net 11 06-10-2005 09:47 PM
Re: Code Behind vs. no code behind: error Ben Miller [msft] ASP .Net 1 06-28-2003 01:46 AM



Advertisments