Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
|
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 24th, 2007, 09:52 AM
Friend of Wrox
 
Join Date: May 2005
Posts: 149
Thanks: 0
Thanked 0 Times in 0 Posts
Default use app_code vb class instead of codebehind

Hi,
I have got a web blog application
the person who has designed it has put all the code in app_code vb classes
how is that? he has ot used codebehind he has just referenced from the pages to the classes like this: inherits="myNamespace.blog"
what is the advantage?is it more professional?
is the any good article about this object oriented programming
here is some sample code:
Namespace myNamespace


    Public Class Blog
        Inherits System.Web.UI.UserControl
        <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

        End Sub
        Private designerPlaceholderDeclaration As System.Object
        Protected WithEvents LblMember As System.Web.UI.WebControls.Label

        Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
            'CODEGEN: This method call is required by the Web Form Designer
            'Do not modify it using the code editor.
            InitializeComponent()
        End Sub

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

            If Not Page.IsPostBack Then
                LblMember.text = "title"


            End If
        End Sub


    End Class

End Namespace


 
Old July 24th, 2007, 06:09 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Is there an advantage to using what? Code Behind files vs Not using them or the advantage to using class files?

Personally, I prefer using Code Behind Files because of the seperation of UI and Logic although I do not know of any ups or downs of one method over another. (If there are advanatages and disadvantages id love to hear them)

In so far as Class files are concerned, that is a professional way of doing things. By and large my app_code directory can be broken down into 2 main categories:

DataAccess Layer
Objects

By and large all of the class files associated with my Data Access layer do just that: Access Data. The objects can be any code that I plan to reuse time and time again through out my project. A simple google search on OOP Principals should net you lots of good reads.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for:
Professional Search Engine Optimization with ASP.NET

Professional IIS 7 and ASP.NET Integrated Programming

================================================== =========
 
Old July 25th, 2007, 10:12 AM
Friend of Wrox
 
Join Date: Feb 2006
Posts: 116
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi keyvanjan,

I just wanted to add that it might be worth keeping in mind that code behind files ARE class files, or to be more exact, partial classes. You will notice they all by default inherit from System.Web.UI.Page.

Also, I recently saw an application recently that took this approach as well, with every "code behind" actually in the App_Code directory. My only thought is that to some people this seems like a better way to organize their classes. It's entirely preferential though. Neither way is more "professional" in my opinion.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Making an Alteration to an VB Codebehind file Nostromo77 ASP.NET 2.0 Basics 4 April 24th, 2007 08:11 PM
App_Code class compiled twice? xxx exists in both bigluzer General .NET 5 January 5th, 2007 03:45 PM
Renaming App_Code jacob .NET Web Services 5 July 4th, 2006 12:20 AM
different class between vb and c#(two books) yonghoo BOOK: ASP.NET Website Programming Problem-Design-Solution 8 September 1st, 2004 08:28 PM
How to include c# class and vb class in the .vbprj umeshayk VS.NET 2002/2003 2 January 9th, 2004 12:08 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.