code behind in ASP.NET

bungpeng

Well-known member
Joined
Sep 10, 2002
Messages
906
Location
Malaysia
In ASP.NET, we can easy programming the web application with codebehind feature.

But, is it practical? logically it should slow down the process right? normal ASP programming is more straighforward...

what is your opinion?
 
I know use code-behind is very convenient for developer, but in web application "SPEED" is a critical issue...

Our opinion is, convenient to developer is not important, the most important is convenient to end-user... I think you should agree right?
 
Even if you dont use Code-Behind, you will use classes and
inheratance, imports and all that good stuff that .NET is all about.
So you will still end up with many pages of code-behind-the-
scenes anyway. Whether its youre own library or something
shipped with the Framework, whats the difference? Its all compiled.
 
Compiled Fast, Conventional slow

Pretty much answers it.

Code behind is better for the developer, end-user and seller:

1.) Apps built with code-behind can be distributed as DLLs - hence your application is protected and your code encapsulated.

2.) For graphic developers and programmers the code/graphics are split up for the most part. Hence your graphic guru will not overwrite your 400 line class file that makes a mokey shoot fruit out of his butt.

3.) If programmed correctly the code should be separed into regions which makes the code very easy to read/troubleshoot/add. Yes that only works for VS developers, but hey, its worth using just for the regions.... An example is attached..... This is an actual suite of applications that I wrote. (sorry for the format, it was done quickly)

4.) Logically it DOES NOT SLOW down the process and in some cases will speed it up. To really see how effecient your code is you will need to test it, and also look at the MSIL code that is created from your app.

5.) Normal asp programming makes much greater sense, UNTIL you learn .net -- you will find yourself saying "oh, thats how you do that, or why didnt they just call it THIS and I would have known what they meant." - it all has to do with mindset. MS is trying to re-program you. In the long term you will see the benefits, and you will see similiarities when working with other O/S and apps.

Hence:
Object
Context
Container

Since Win98 for example, everyting is object based. Did you notice that when you opened the explorer that it used to say "14 folders and 344 files"? -- Now it will say "14 objects" or "344 objects"

---------------------------------------------------

:-\
 

Attachments

1. Compare with ASP (not ASP.NET), I still can use DLL in ASP.
2. For code behind, we need to use Web Control, it definitely slower than HTML Form control.
....

I will test the different of the speed to get my answer. Logically I believe code-behind should be slower, but I need to know how much slower...

Anyway, thank you for your reply.
 
Code-behind pages and the code at the top of ASPX pages (in
the header) will be compiled into a DLL before you can see the
changes in the code. This makes it lightning-fast.

Another good point brought up on the most recent episode of
VBTV (and in point #2 in aikeiths post) is that code-behind pages
help separate the UI from the code, and it can help keep things
organized for collaborative projects where different people are
working on the UI and the actual code.

Code that is in the page between <% %> brackets, however, is
not compiled, and is evaluated whenver the page is accessed.
This makes it much slower than the code-behind code or the code
at the top of the page.
 
"Compare with ASP (not ASP.NET), I still can use DLL in ASP."
It is very easy in ASP.NET.

" For code behind, we need to use Web Control, it definitely slower than HTML Form control."
Code-Behind and Web Controls dont go hand-in-hand, you can use one without the other.
 
You can do this...
Code:
PlaceHolder1.Controls.Add(New LiteralControl("<body bgcolor=#F8FFBF>"))

or just send any HTML tag within a control...
Code:
Label1.text = "<table width=600 style=color: #000080><tr><td><b>Some Text</b></td></tr><table>"
 
Back
Top