To Code Behind or Not Code Behind, That is the Question...

I have been working in ASP.Net 1.0 for several years.  I have just begun using 2.0 and I am really liking it.

I understand how to create pages with code in the page and code behind the page.  I'm just not clear on what is considered the preferred method.

I am about to start a new application and I would like to do it the recommended way.

Are there any opinions on this already, something I should be reading?

Thanks a lot,

Chris

0
CMessineo
12/4/2006 10:33:33 PM
asp.net.migrating-from-1.x-2.0 1016 articles. 0 followers. Follow

7 Replies
953 Views

Similar Articles

[PageSpeed] 15

Hi,

  Generally, code behind, or code behind files are recommended, as they make applications easier to debug and rework.  I guess that the thinking is, that it's easier to read through something that is just code, without having to skip past html source; and easier to see the flow of your html, without being interupted by script.  Those people that were comfortable with the style of 'classic' ASP (with the script and html mixed), can stay with that pattern - after all the tools are supposed to let you work the way you want to, rather than force you to change something that works for you.

  In making up your mind, you should take a look at the Web Application Projects add on to Visual Studio 2005 - there's a very good tutorial video in the Learn tab on this site, that covers the implications of this addition.  Even if you aren't using VS 2005 at this time, you'll want to know about the two models that are used to complile an application - this is what the WAP add on is concerned with.  Different patterns of development, and different expectations for deployment will effect which choices you make for your development coding.  I think the diffences in the two models is profound, and is often not mentioned in introductions to ASP.Net.  It's not something you need to know to get started, but you will be starting down one path or another, and the two paths lead to different places - so it's worth looking at before you commit to one pattern or another.

  Hope it helps.  BRN..
 

0
Brian27
12/9/2006 12:55:59 PM

If I'm just converting classic ASP to ASP.NET by making asp files as aspx and changing the syntax a little to suit ASP.NET, can I create a code-behind file? How?

Is there any advantage to specifically creating a code behind file?


Regards

Partha Mandayam
Sr Prog Analyst
Kaiser Permanente

0
mcp111
2/9/2007 8:27:30 PM
Converting from asp to asp.net, it will be easier to create single.aspx files without code behind.
AT2007
0
aniltripathi
2/9/2007 8:57:33 PM
Thanks
Regards

Partha Mandayam
Sr Prog Analyst
Kaiser Permanente

0
mcp111
2/9/2007 9:44:55 PM

mcp111:
Thanks

You can also use the "Not Code Behind" but the bigger your project, the more the lines of codes (LOC), and the more it will be cluttered. So as Brian said before, it is much cleaner to use the Code Behind but still, the options are still yours.

 


Microsoft Student Partners

Willy David Jr
Junior Software Development Engineer
Gurango Software Corporation

Programming is a Passion, Software Development is an Adventure - willydavidjr
0
willydavidjr
2/10/2007 5:28:24 PM
If I'm just renaming asp to aspx and making few syntax changes, how can I create a code-behind file? For a new page if we check the box, vs2005 automaticaly creates a code behind file - how to do it for converted pages?
Regards

Partha Mandayam
Sr Prog Analyst
Kaiser Permanente

0
mcp111
2/12/2007 1:58:19 PM

Is there a definite speed improvement when you covert your aspx pages to code-behind-code?  I have built my website with asp.net code and html all on one page...with a SQL 7 backend.

 The speed is not very fast....and my coder suggested he spend 20 hours (billable) to switch to code-behind-code.  Is it worth it?

 (I have a membership site and need to support several hundred concurrent members)

0
blaster998
3/23/2007 9:53:30 PM
Reply:

Similar Artilces:

How do you code yours? Design Time or Code Behind (.net 2.0)?
What’s your preferred method when coding?   I have noticed in a lot of books and even the Quick start Tutorials section of the site they use Design Time examples using Drag and Drop examples with visual studio. Surely having code in your .aspx file such as asp:ObjectDataSource is not the best method. Surley the best method is to use classes with code behind?   Your comments would be very much appreciated.   Thanks   WD ThanksWDRocket Whois - http://www.rocketwhois.co.uk/ IMO, it depends on what you are doing. If you are creating one web form or a very small sit...

Code Behind or not Code Behind
Ok i am confuse now.... A lot of books are showing pages without code behind (the code is integrated in the .aspx) Is it better to use the code behind or not. Is there any difference between using VB.NET or C#.NET except for the code synthax. Thank you and come again. A lot of samples show inline code just for simplicity.. i personally use code-behind because I like to seperate my code from presentation. As for VB.NET or C#, its your preference.. there is no difference really when its all said and done. From a purely mathematical sense, having everything in a single file would s...

what about the code-behind (code behind)
One MAJOR difference between AJAX.NET and Atlas.NET seems to be that AJAX.NET is able to expose methods in your codebehind to the client. Why doesn't Atlas do this? Or am I mistaken? With AJAX.NET it's just a simple line or two:  Ajax.Utility.RegisterTypeForAjax(GetType(myClass)) <Ajax.AjaxMethod()>Public Function myFunction PLEASE tell me Atlas has something comparable to this. I don't have the time to rewrite all my code-behind methods in javascript or atlas script. All you need to do in Atlas to expose a method on your page (or its code behind class) is to put a [WebMet...

Inline Coding (i.e. no Code-behind) and Wilson Pages (.Net 1.1)
Hi, I'm developing a personal web site and planning on hosting it on Brinkster, but Brinkster does not allow codebehind or using Dlls (from what I understand). But I would still like to use Wilson Master Pages, if possible.  I downloaded the free source code from the Wilson Master Pages website, but I'm not an advanced enough .Net programmer to firgure out how to use the source code using inline code.  Normally, you would use something like:<%@ Register TagPrefix="Wilson" Assembly="WilsonMasterPages" Namespace="Wilson.MasterPages" %>  on your templated pages...

Code behind vrs. non code behind in VS.NET 2003
Does anyone know what the advantages and disadvantages are for using code behind vrs. non code behind in Visual Studio.Net 2003? One important difference is that you are able to separate the design of a web site from the code. This makes for ease of maintainablity and much more structured applications. If you ever worked with classic ASP the code-behind is a great invention. sivilianMy Weblogs...

Is there a way to deploy 2.0 web site without the code behind (like 1.1)
I made a 2.0 application, but when moving on the host server I notice it doesn't build like it did with 1.1.  Before I could just put the aspx pages out there and the bin directory.  Now I have to load all of my code.  That doesn't seem very safe.  Is there a way to build the 2.0 applciation so all I would need is the aspx files and the dlls?   Thanks! Use the "Publish" option of VS2005.  It creates compiled assemblies of your codebehinds and pages.  If you deselect the option "Make this site updateable" you even remove the aspx code from the pages...

Code works with .Net 1.1 but not .Net 2.0
Can anyone offer any suggestions as to why this code would work under .Net 1.1 and not .Net 2.0? I listed the error I receive below, also. Line 865. Thank you, Public Function GetAge(ByVal Birthdate As System.DateTime, _ Optional ByVal AsOf As System.DateTime = #1/1/1700#) _ As Integer Dim iMonths As Integer Dim iYears As Integer Dim dYears As Decimal Dim lDayOfBirth As Long Dim lAsOf As Long Dim iBirthMonth As Integer Dim iAsOFMonth As Integer If AsOf = "#1/1/1700#" ...

LDAP Authentication .Net 1.0 code to .Net 2.0
A few years ago with help of Dunry (I think he wrote most of the LDAP part) we came up with the below C# that works in our environment. We now need to migrate this to .Net 2.0.Does anyone have any examples of something simliar that works in .Net 2.0? Thanks in advance.private void btnSubmit_Click(object sender, System.EventArgs e)  {   if(Page.IsValid)   {    SearchDirectoryUsername(txtUsername.Text);   }  }  private void SearchDirectoryUsername(string username)  {   using ...

Differences between .net 1, .net 1.1, .net 2.0 and .net 3.0 #2
Hi, This seems to be a common question, but i havent got an answer yet:(Can, any one please explain me the differences between these versions.If you keep your feet firmly on the ground, you'll have trouble putting on your pants! There are too many differences for one email - - from 1.0 to 1.1 (not a whole lot of real change, other than fixes, at least compared to 1.1 to 2.0) With 2.0, there were many new declarative controls, with many new ideas added in With 3.0, it's a superset of 2.0 - instead of replacing the installation completely, it just 'added on' new functionality - I would...

Code Behind vs. Non-Code Behind
If you do not use Code Behind will the only thing you need is the .aspx file??? What is the benefit of code behind? I want to know the benefits.Moojjoo Õ¿Õ http://www.mmwebs.comhttp://moojjoo.blogspot.com/ The reason I ask about benefits is because everybook or place I read about ASP.net they do not, I repeat "DO NOT use CODE BEHIND" Even my MICROSOFT ASP.NET Step by Step book does not use it.Moojjoo Õ¿Õ http://www.mmwebs.comhttp://moojjoo.blogspot.com/ From a runtime perspective there is very little difference, howev...

code behind vs non code behind
hi,How do I gain access to server objects and events when I am using code behind? When I am using code behind in C#, I do not have access to server objects & events on my drop down list. However, when I do not use code behind, I have access to server objects & events on my drop down list.  Thanks.  You always have access to server controls from code-behind.  If your dropdownlist ID="DDL1", you can access it using Me.DDL1Please remember to click “Mark as Answer” on the post that helps you.This can be beneficial to other community members reading the thread.T...

Conversion of code from .net 1.1 to .net 2.0 posing a problem
Originally Posted by Akshay_Jadhav on the Microsoft Interoperability - Technical Interoperability Scenarios forumHI,I have converted .net 1.1 code to .net 2.0 using .net wizard. i have radiobutton whose checked property is set to false on page load, on clicking of a button on that page checked property of radiobutton is set to true and a dropdownlist is enabled. when i select some value in dropdownlist the page is posted back and checked property of radiobutton is again set to false(automatically) which is wrong, it should be true. Same code is working fine in .net 1.1,when i select som...

Code-behind database query? (C#.NET 2.0)
Just a simple question...  How could I use a database query in my back-end code? (I have a feeling there's a better name for that code, it's just not coming to mind.)This is what I've tried:protected String Forward() { string r = Eval("Rank"); } But it rather disapproves of that.  That particular String has an if statement in it and is used in my front-end page to set a link.  How can I set that variable to what Rank is defined as in my query? If the Forward() function is being called from your UI (ASPX) as part of a databinding operation, I think you need ...

.net 2.0 and 1.1 code
hi,will anything developed for .net 1.1 still work ok with .net 2.0? (As provided in the microsoft express downloads)?thanks.regards,sell4u_uk Hi Sell,If you are using Visual Studio 2003 today, then you will want to use Visual Studio Standard 2005 or higher for web development on 2.0.  Not all of the features you have in VS 2003 are available in the free express download products (for example: Visual Web Developer doesn't support standalone class libraries -- that feature is only available in VS Standard and above).Hope this helps,Scott...

Web resources about - To Code Behind or Not Code Behind, That is the Question... - asp.net.migrating-from-1.x-2.0

German question - Wikipedia, the free encyclopedia
"Kleindeutschland" redirects here. For the neighborhood in New York City, see Little Germany, Manhattan . 1820 map of Central Europe showing ...

James Ashby, Mal Brough question editing of crucial Channel Nine interview about Peter Slipper diary ...
Two central figures in the Peter Slipper diary affair cast doubt on a key interview that aired on Channel Nine last year.

Geraldo Rivera Didn’t Get to Question Pres. Obama in Paris
Fox News host Geraldo Rivera can’t catch a break. He’s in Paris reporting on the aftermath of the terror attacks ( which hit close to home ) ...

Submit Your Questions For Autoblog Podcast #457
Filed under: Podcasts On Episode #457 of the Autoblog Podcast, we'll discuss the just-unveiled Volvo S90, Faraday Future, and this week's news ...

More questions emerge over Trump's 9/11 celebrations claim
Washington Post More questions emerge over Trump's 9/11 celebrations claim CBS News Republican presidential candidate Donald Trump is continuing ...

Claims of deleted video among questions in Chicago shooting
Chron.com Claims of deleted video among questions in Chicago shooting Chron.com CHICAGO (AP) — The release of squad-car video showing a white ...

The bigger question about the Fed
While the timing of the first rate hike has long been one of the market's most pressing questions, investors appear to have moved on to another ...

Judge applies common sense to question of what constitutes a data breach
Enterprise security is a frustrating game, because IT winning 99.9% of the time isn’t enough. One lucky cyberthief or one careless employee — ...

Lawmaker Questions Airlines, Plane Manufacturers On Cybersecurity Measures
Eight months after a government report found that airplanes with WiFi connections may be vulnerable to cyber attacks and seven months after a ...

Rahm Emanuel Says He Didn’t Watch Shooting Video To Avoid Answering Reporters’ Questions
Rahm Emanuel Says He Didn’t Watch Shooting Video To Avoid Answering Reporters’ Questions

Resources last updated: 12/3/2015 12:52:42 AM