Wednesday, July 11, 2007

Why .NET Framework and Visual Studio

1. Getting More Help!
A. On Line Help in VS is good! Use it!
B. Our on line tutor:sledwith@saddleback.edu
C. http://www.dotnetjunkies.com/search.aspx
2. What is the .NET Framework
A. Common Language Runtime (CLR)
1. Previous: All languages had their own “runtime engine”
a) VBrun…. MSVCRT (C++) etc
2. Now: All .NET languages use the same runtime engine.
B. .Net Framework Classes
1. Previous: Each language has it’s own “API” or objects with their own capabilities…so everyone thought they were better.
2. Now: All .NET languages share the same “Class Libraries” or objects
a) Think boxes of code that you can open and use in any language.
C. Why .NET Framework
1. Use any language, any device, any location…all work together
2. Plumbing is already done: No more “registry code” or “memory management” code
3. Takes care of all the XML and SOAP for you.
4. Better optimized so FASTER!
D. Path from your code to a running application?
1. VS uses the CLR to create “managed code” or code created by/for the .NET Framework.
a) MSIL: Microsoft Intermediate Language.
b) This goes in the EXE or DLL
(1) Just text; can be edited…
2. The Just In Time Complier (JIT) in the .NET Framework
a) Translates the MSIL into something your processor / OS can handle.
3. New: Data is stored locally in a DataSet as XML (with schema) and is disconnected for the data source. Think Web…local database!
3. What is Visual Studio.NET
A. The .NET framework (classes and CLR) are all free.
1. Don’t have a life? Program to .NET with Notepad. Very tough but doable.
B. Visual Studio.NET provides a developer friendly front end to .NET
C. What languages: Dozens but 5 big ones
1. VB.NET (most common)
2. C++.NET (.NET is written in this)
3. C#.NET (user friendly C++)
a) No pointers, no memory management, has string data type
4. J++.NET (Java like)
5. J#.NET (just came out..user friendly J++)
6. Bottom Line…all use the Framework = Intermediate Format.
D. What languages are NOT in .NET
1. VB script or Java script…no more “scripting languages”
a) But makes a find ASP script ‘editor’
2. ASP.NET…this is not a language..
a) It’s a combination of technologies (including one of the languages above) to create server side web applications.
E. Common Data Types
1. All share same “types” but different languages user different names
2. See chart in the book.
3. String is a different animal…it is not a simple value type…it is an object
4. There is a date data type….
F. What types of apps can you create?
G. Windows Applications: (Run locally)
1. Windows Forms: Classic windows applications but much more portable.
2. Windows Services: (NT, 2K and XP) run in the background all the time.
a) No GUI, think scheduler service.
H. Web Applications: Run on Web Server
1. Web Application (interacts with User: Think Amazon.com)
a) ASP.Net = provides capabilities of .Framework to Web based applications
(1) ASP scripting is still doable but not ‘managed’
b) ASP.Net Web Forms (GUI option for Web app)
(1) Like Windows forms but for the Web
(2) Replaces the HTML form controls of ASP
(3) All server side! Not browser specific.
I. Web Services (interacts with another program.)
1. Think Credit Card Authorization
J. Class Libraries
1. DLL’s with functions you can call in other applications
4. Versions: Visual Studio .NET 2003
A. Develop for mobile devices
B. Uses .NET Framework 1.1 (security, performance, enhancements)
C. J#
D. Improved Debugger
E. New IDE provides improved start-up time, performance, and reliability
F. New managed providers offer easy access to Oracle 7i, Oracle 8i, and ODBC data sources
G. General clean up from the introductory version.
5. Installation: Easy but long!
A. Windows 2K (pro or server) XP, 2003
1. If 2K Pro or XP then install IIS first.
B. It will ask for the component update CD first
C. Then choose which parts to install
1. VB & Crystal for this class
6. Optional: Creating an IIS (Web Server) Virtual Directory for your apps
A. Default…they end up in wwwroot of localhost
B. Create a folder to hold your projects.
1. Example: dotNetProjects
C. Right click on My Computer . Manage . Services . Internet Information Services .Drill down to Default Web Site . Right click . New
D. Virtual Directory . Name (short!) . Location is the folder you created.
E. Accept defaults
7. *Configuration
A. Tools .Options . Text Editor . Basic .
1. Uncheck hide advanced members
2. Uncheck Word Wrap
3. Check line numbers (helps with debugging)
B. Tools. Options . Environment . Projects & Solutions…
1. IF you created a virtual folder to hold your web applications you can default to it here.
C. Note Projects . Web Settings: Location of VSWebCache
1. You can move this but in any case you may have to clear this folder out.
8. Making Flow Layout the default choice.
A. C:\Program Files\Microsoft Visual Studio .NET 2003\Vb7\VBWizards\WebApplication\Templates\1033
1. and
B. C:\Program Files\Microsoft Visual Studio .NET 2003\Vb7\VBWizards\WebForm\Templates\1033
1. Always make a backup before changing!
C. Change WebForm.aspx
1.
2. to just (take out the MS_......)
9. To make Option Strict the default. (Pain; but you only have to do it once!)
A. Start . Search . Files or Folders
B. Search for: *.vbproj
C. Look in: C:\Program Files\Microsoft Visual Studio .NET\Vb7\VBWizards
D. Edit these files and add the OptionStrict = “on” such as



OptionStrict = "on"
E. …….more settings.
10. Solutions, Projects and general file layout.
A. Projects are the Web folders that contain your web project
1. One language per Project
2. Project file is the key.
B. Solution is just a grouping of projects…for organizational purposes
1. Each project must be in a solution.
2. Common to have one solution and one project same name.
11. Creating a new project (File . New or Ctrl N)
A. Left: we will be working with VB projects
B. Right are the project types
1. Windows application are the classic VB6 apps
2. ASP.NET Web Applications are what we will be doing
C. Note that ASP.Net will ask you for a server and project folder (name)
1. The server you choose must have .NET framework on it.
2. Folder you create becomes a virtual directory (folder) on the Web Server
3. The name of the project is the Folder Name.
D. After creating the Web app .NET connects to the web server and builds the directory.
1. Loads it with appropriate files
12. First Steps with new project (if defaults are not set)
A. Project Properties . Build . Option Strict On
B. Project Properties . Designer Defaults . Page Layout Flow
13. How to rename a form: 3 steps
A. Right click on form and rename
B. Open the code window and change the Public Class newname
C. Open the HTML and check first line “Codebehind="newname….”
14. Adding a Web page…easy. Right click on Project . Add . Web Form
15. The IDE (Intergraded Development Environment)
A. Two types of windows: Tool Windows and Document Windows (you type)
1. Tool windows come with VS, Document windows you create
a) Tool Windows have push pins
2. Dock with double click vs dragging the border
16. Working with Tool Windows….lots
A. Autohide or not….
1. Push pin to side…autohide on…
a) pin pointing down…window is pinned down = autohide off
B. If autohide off then window can be docked or float
C. If float then you can drag them onto a second monitor.
D. If dockable…double click on title bar to undock
1. Now watch as you click and drag on the title bar
2. Slowly and you can see the grey outline.
a) Can dock in at least three formats…top, bottom and tabbed
17. Toolbox: Ctrl Alt X (for box)
A. Lots of stuff here…note the clipboard ring (last 20 items on the clipboard)
B. Not in alpha order. Order of most commonly used
C. After placing a tool on form
1. That green icon in the left top corner indicates a server-side control
a) (1)Control that is generated on the server and accessible in server-side code.
b) Server-side control don’t really exists. They are IDE place holders for the HTML control that the server will create on the fly.
2. Web Controls are ALWAYS server-side controls.
a) HTML controls CAN be server side if you add an ID attribute and the runat="server" attribute.
3. Client side controls are usually pure HTML.
18. Solution Explorer: Alt Ctrl L (for ‘List’)
A. List of files you can edit in your project
B. Buttons at top
1. First two switch between design and code windows
a) Hint. F7 and Shift F7 (thank heaven for code window)
2. 5th window will show all files.
C. CAREFUL
1. Right click on Solution is different than right click on project
2. Both have own (but different) ADD and Properties
19. Server Explorer: Ctrl Alt S (for server)….very cool
A. Provides access to ‘services’ running on your box or other server
B. Most obvious is SQL data services
C. But also have access to performance monitor, event viewer etc.
20. Properties Page (F4)
A. Properties for the current object
B. Note that the properties page (right click) is different from F4 properties
C. Tip. Changing properties is just “editing” the HTML view.
1. Both do the same thing.
21. Task List (Ctrl Alt K): More than a ToDo list
A. Includes build errors
B. Double click on error in task list and it takes you to the error.
22. Help: Is Excellent (F1) but requires entire MSDN (lots of disk space)
A. Context Sensitive: F1 while on the item to get help on.
23. Editing Window
A. A Web Page is actually made of two pages
1. .apsx is the Design page…what you see
a) This has two views: Design and HTML (note buttons at bottom)
2. .aspx.vb is the “code behind” page
B. Switching: Double click on Design page to get to code
1. Or use buttons at the top of the properties.
2. F7 and Shift F7
C. Change the Edit Window from Grid to Flow layout
1. Document Properties (F4). PageLayout.
24. Using the Text Editor
A. Hint: Check out Edit . Advanced menu
1. Format is handy in HTML view
B. IntelliSense: As you type it gives hints
1. Ctrl J to force it
2. Ctrl Spacebar to autocomplete.
a) Space to complete and leave a space.
b) Tab complete and not space
c) Enter complete and new line
C. Can Split the window with the splitter bar
D. Use Find (Ctrl + F) and Replace (Ctrl + H)
1. But only currently opened files
a) Note find box in tool bar
E. Edit . Find & Replace: Find in Files
1. All files!
F. Auto Indent
1. Auto lines up code no matter where you start
2. Auto indents Ifs and loops
a) Highlight your un indented code…then press tab
G. Word Wrap (use with caution)
1. Ctrl R + Ctrl R
H. Incremental (or search as you type) search (Ctrl Alt I)
1. Note the bino icon.
2. And start typing…it will find the next search
I. Bookmark code (Ctrl K, K) turquoise mark
1. Ctrl K , N to go to the next mark
J. Commenting code: (Block comment from the text editor tool bar)
1. ‘ is used for a comment.
2. Note toolbar
K. Full Screen: Alt Shift (All Stuff) Enter
L. Ctrl Tab between windows or tabs
25. Build & Run your Web Forms: Set START PAGE!
A. F5: With debugging (slower but lots of information):
1. Right click in solution explorer on a page to set the start page
a) Hint…set a break point to pause the debugger
2. F5 to start the debugger
3. Shift F5 or close the browser to stop the debugger
B. Without Debug but in a browser (ie real life)
1. Set a start page
2. Ctrl F5
C. Without Debug but within VS running as if in browser (FAST!)
1. Right click on solution explorer page: Build and Browse
2. If nothing has changed you can just select Browse
a) If something has changed Browse will ask you to save changes
(1) Same as Build and Browse
26. ASP.NET files: (you can open in notepad)
1. .sln: note the location of the web site
2. vbproj.webinfo: note the location of the web site.
a) This file can be deleted between runs
3. You can delete the .suo between runs