SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Addict jlisec01's Avatar
    Join Date
    Nov 2006
    Location
    MI
    Posts
    331
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Having all code on a separate file?

    Hi there, I wanted to stay organize with my code, and I was just wondering, when I make my web pages I usually put all my code inside the script tag of the head tag, I was just wondering if it was possible to have all my code in a separate file in the same directory instead of using it all in the head section, thanks for any help I really appreciate it.

  2. #2
    Chopped Liver bronze trophy imaginekitty's Avatar
    Join Date
    Aug 2007
    Location
    Pennsyltucky
    Posts
    1,494
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    You mean like using a codebehind file?

  3. #3
    SitePoint Addict jlisec01's Avatar
    Join Date
    Nov 2006
    Location
    MI
    Posts
    331
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes that is correct.

  4. #4
    SitePoint Zealot iScrawl's Avatar
    Join Date
    Mar 2009
    Posts
    112
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's always a good idea to keep your code as tidy as possible.
    When I worked alone, I used to have huge files of code, but when I started to work with a team of 40(!) developers, I got to know how hard it is to work like that, and how important is to separate the code to small files so anyone can have their piece of code...

    And sure, it's very easy to do in .NET, just create a new file as module file, and call the functions...
    Hanan Moiseyev
    Online games and Videos - http://www.playwithroger.com
    Share your art - http://www.iscrawl.com

  5. #5
    SitePoint Addict jlisec01's Avatar
    Join Date
    Nov 2006
    Location
    MI
    Posts
    331
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm getting a compilation error, display.aspx has:

    Code VBNET:
    <%@ Page Inherits="display" Src="display.vb" %>

    then display.vb is where the error is occuring, says txtSearch is not declared.

    Code VBNET:
    Imports System
    Imports System.Web.UI
    Imports System.Web.UI.WebControls
    Imports System.Data.OleDb
     
    Public Class Display
      Inherits Page
     
    Sub getStudentData(s As Object, e As EventArgs)
    	Dim objConn As OleDbConnection
    	Dim objCmd As OleDbCommand
    	Dim objRdr As OleDbDataReader
            objConn = New OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;Data Source=" &server.mappath("CollegeDB.mdb"))
    	objCmd = New OleDbCommand("SELECT * FROM STUDENT WHERE FIRST_NAME=@FIRST_NAME", objConn)
    	objCmd.Parameters.Add("@FIRST_NAME", txtSearch.Text)
    	objConn.Open()
    	objRdr = objCmd.ExecuteReader()
    	myRepeater.DataSource = objRdr
    	myRepeater.DataBind()
    	objRdr.Close()
    	objConn.Close()
    End Sub
     
    Sub Logout(s As Object, e As Eventargs)
      FormsAuthentication.SignOut()
      Response.Redirect("login.aspx")
    End Sub
     
    End Class

  6. #6
    SitePoint Addict
    Join Date
    Feb 2005
    Location
    Clogland
    Posts
    322
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Instead of
    Code VBNET:
    src="display.vb"
    use
    Code VBNET:
    CodeFile="display.vb"
    instead.

    Are you not using Visual Studio (Express)? It will do this all automatically for you.

  7. #7
    SitePoint Addict jlisec01's Avatar
    Join Date
    Nov 2006
    Location
    MI
    Posts
    331
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by SlitheryImp View Post
    Instead of
    Code VBNET:
    src="display.vb"
    use
    Code VBNET:
    CodeFile="display.vb"
    instead.

    Are you not using Visual Studio (Express)? It will do this all automatically for you.
    I'm using notepad at the moment :\ but,
    I get an error that says, could not load type 'display'.


Bookmarks

Posting Permissions

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