ebook img

Essential ASP.NET™ fast : with examples in VB .Net PDF

242 Pages·2003·14.41 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Essential ASP.NET™ fast : with examples in VB .Net

Essential Series Springer-Verlag London Ltd. Also in this series: John Vince Fiaz Hussain Essential Virtual Reality fast Essential Flash 5.0 fast 1-85233-012-0 1-85233-451-7 John Cowell John Vince Essential Visual J++ 6.0 fast Essential Mathematics for 1-85233-013-9 Computer Graphics fast 1-85233-380-4 John Cowell Essential Java 2 fast John Cowell 1-85233-071-6 Essential VB .NET fast 1-85233-591-2 John Cowell Essential Visual Basic 6.0 fast Simon Stobart 1-85233-071-6 Essential PHP fast 1-85233-578-5 John Vince Essential Computer Animation fast Fiaz Hussain 1-85233-141-0 Essential Dreamweaver 4.0 fast 1-85233-573-4 Aladdin Ayesh Essential Dynamic HTML fast Aladdin Ayesh 1-85233-626-9 Essential UML fast David Thew 1-85233-413-4 Essential Access 2000 fast Ian Stephenson 1-85233-295-6 Essential RenderMan fast Ian Palmer 1-85233-608-0 Essential Java 3D fast Dan Lavender 1-85233-394-4 Essential Maya 4 fast Matthew Norman 1-85233-588-2 Essential ColdFusion fast 1-85233-315-4 Ian Chivers Essential Linux fast 1-85233-408-8 Simon Stobart Essential ASP.NET™ f a s t with examples in VB .NET , Springer Simon Stobart, BA(Hons), Ph.D, MBCS, CEng School of Computing and Technology, University of Sunderland, Sunderland SR6 ODD Series Editor John Cowell, BSc (Hons), MPhil, PhD Department of Computer Science, De Montfort University, The Gateway, Leicester LEI 9BH British Library Cataloguing in Publication Data Stobart, Simon Essential ASP.NET fast: with examples in VB .NET. - (Essential series) 1. Active Server Pages (Computer file) 2. Internet programming 3. ASP.NET fast 005.2'76 ISBN 978-1-85233-683-7 ISBN 978-1-4471-0005-8 (eBook) DOI 10.1007/978-1-4471-0005-8 Library of Congress Cataloging-in-Publication Data A catalog record for this book is available from the Library of Congress Apart from any fair dealing for the purposes of research or private study, or criticism or review, as permitted under the Copyright, Designs and Patents Act 1988, this publication may only be reproduced, stored or transmitted, in any form or by any means, with the prior permission in writing of the pubJishers, or in the case of reprographic reproduction in accordance with the terms of licences issued by the Copyright Licensing Agency. Enquiries concerning reproduction outside those terms should be sent to the publishers. Essential series ISSN 1439-975X ISBN 978-1-85233-683-7 http://www.springer.co.uk © Springer-Verlag London 2003 Originally published by Springer-Verlag London Berlin Heidelberg in 1997 The use of registered names, trademarks etc. in this publication does not imply, even in the absence of a specific statement, that such names are exempt from the relevant laws and regulations and therefore free for general use. The publisher makes no representation, express or implied, with regard to the accuracy of the information contained in this book and cannot accept any legal responsibility or liability for any errors or omissions that may be made. Typesetting: electronic text fIles prepared by the author 34/3830-543210 Contents 1. WHY USE ASP.NET? ........................................ 1 Introduction ................................................................................................................................. 2 What do I need? .......................................................................................................................... 2 Is this book for you? .................................................................................................................... 3 How to use this book .................................................................................................................. 4 Don't Type! .................................................................................................................................. 5 2. THE ASP.NET ENVIRONMENT ......................... 7 Introduction ................................................................................................................................. 8 Basic Software Components ...................................................................................................... 8 Installing Internet Information Server ...................................................................................... 8 Running Internet Information Server ..................................................................................... 11 Obtaining the .NET Framework ............................................................................................... 12 Your ASP.NET Development Directory ................................................................................... 13 Summary .................................................................................................................................... 13 3. INTRODUCING ASP.NET ................................. 15 Introduction ............................................................................................................................... 16 A Simple HTML Document ....................................................................................................... 16 What is ASP.NET and ASP? ....................................................................................................... 18 First ASP.NET Script .................................................................................................................. 19 Alternative Script ...................................................................................................................... 22 Error Messages .......................................................................................................................... 23 Static and Dynamic Web pages ............................................................................................... 25 How is ASP.NET Different? ....................................................................................................... 26 Formatting ASP.NET Instructions ............................................................................................ 28 Jumping in and out of ASP.NET.. ............................................................................................. 29 The Response.Write Object ...................................................................................................... 30 Summary .................................................................................................................................... 31 4. VB. NET BASICS .............................................. 33 Introduction ............................................................................................................................... 34 Essential ASP.NET fast Variables .................................................................................................................................... 34 Assigning values to variables ................................................................................. 34 Explicit Variable Declarations ................................................................................. 35 Different Types of Variables ................................................................................... 35 Integer Numbers ...................................................................................................... 36 Floating point (real) numbers ................................................................................ 37 Other data types ...................................................................................................... 38 Declaring and Initialising Together ....................................................................... 38 Constants .................................................................................................................. 38 Automatic Conversion ............................................................................................. 39 Standard Conversions ............................................................................................. 39 Conversion Functions .............................................................................................. 40 Strings ........................................................................................................................................ 40 Expression, Operand &O perator ............................................................................................. 41 Arithmetic Operators ............................................................................................... 41 Assignment Operators ............................................................................................ 41 Comparison Operators ............................................................................................ 42 Logical Operators ..................................................................................................... 43 Loops and Ifs ............................................................................................................................. 43 If Then ....................................................................................................................... 43 Expanding If Then with Else ................................................................................... 44 Elseif .......................................................................................................................... 44 Select Statement ..................................................................................................... 45 Do While and Do Until Top Testing ......................................................................................... 45 Do While and Do Until Bottom Testing ................................................................ .46 For loop and step ..................................................................................................... 47 Arrays ......................................................................................................................................... 47 Subroutines ............................................................................................................................... 48 Subroutines and Arguments ................................................................................................... 50 Functions ................................................................................................................................... 51 Exiting a Function or Subroutine ........................................................................... 53 Summary ................................................................................................................................... 53 5. ASP.NET OBJECTS ........................................ 55 Introduction .............................................................................................................................. 56 Response Object ....................................................................................................................... 56 Randomize ................................................................................................................................. 57 Request Object .......................................................................................................................... 58 Further Request Object Methods ............................................................................................ 61 Request Object Browser Object ............................................................................................... 62 ArrayList Class ...........................................................................................................................6 4 HashTable Object ...................................................................................................................... 67 Contents Summary ....................................................................................................................................7 0 6. INTERACTING WITH THE USER ...................... 71 Introduction ............................................................................................................................... 72 ASP.NET and Forms ................................................................................................................... 72 Server Controls ..........................................................................................................................7 2 Simple Form Processing ........................................................................................................... 73 ASP.NET Server Control Events ................................................................................................ 74 The Page Object ........................................................................................................................7 7 IsPostBack ..................................................................................................................................7 8 Passing non form variables between pages .......................................................................... 81 ViewState ...................................................................................................................................8 4 Page_PreRender ....................................................................................................................... 87 Summary .................................................................................................................................... 87 7. EXAMINING WEB SERVER CONTROLS ............ 89 Introduction ...............................................................................................................................9 0 The Textbox ...............................................................................................................................9 0 Forecolor and Backcolor .......................................................................................... 90 Bordercolor and Borderstyle ................................................................................... 92 Font Adjustment ...................................................................................................... 94 Height and Width .................................................................................................... 96 Te xtmode .................................................................................................................. 97 Columns, Rows and Maxlength .............................................................................. 98 Enabled / Visible ...................................................................................................... 99 ReadOnly ................................................................................................................ 100 ToolTip .................................................................................................................... 101 AutoPostBack ......................................................................................................... 101 The Label ..................................................................................................................................1 05 The Button ............................................................................................................................... 1O S Summary .................................................................................................................................. 106 8. FURTHER INTERFACE CONTROLS ............... 107 Introduction ............................................................................................................................. 108 CheckboxList ........................................................................................................................... 108 Items(x).Text .......................................................................................................... 112 Items(x).Value ........................................................................................................ 113 Items. Count ............................................................................................................ 114 Items.Add ............................................................................................................... 114 Items.lnsert ............................................................................................................ 114 Essential ASP. NET fast Items. Remove ........................................................................................................ 115 Items.RemoveAt .................................................................................................... 115 Items. Clear .............................................................................................................. 115 TextAlign ................................................................................................................ 115 CeliPadding and CeIiSpacing ................................................................................ 117 RepeatColumns, RepeatDirection and RepeatLayout ....................................... 120 AutoPostBack ......................................................................................................... 122 Checkbox ................................................................................................................................. 122 Text ......................................................................................................................... 123 Checked .................................................................................................................. 123 AutoPostBack ......................................................................................................... 124 RadioButtonLists ..................................................................................................................... 124 Selected Index and Selectedltem.Text ................................................................. 128 AutoPostBack ......................................................................................................... 129 RadioButton ............................................................................................................................ 129 Groupname ............................................................................................................ 129 DropDownList ......................................................................................................................... 132 ListBox ...................................................................................................................................... 135 Selection Mode ....................................................................................................... 136 Manipulating Listltems .......................................................................................................... 138 LinkButton ............................................................................................................................... 142 Summary ................................................................................................................................. 143 9. CALENDAR AND ADROTATOR CONTROLS ... 145 Introduction ............................................................................................................................ 146 Calendar ................................................................................................................................... 146 Backcolor and Forecolor ........................................................................................ 148 Firstdayofweek ...................................................................................................... 148 Showgridlines ........................................................................................................ 148 Shownextprevmonth ............................................................................................ 149 Visibledate .............................................................................................................. 149 Onselectionchanged and Selected Date .............................................................. 151 Adrotator ................................................................................................................................. 153 Summary ................................................................................................................................. 156 10. FORM VALIDATION CONTROLS ................... 157 Introduction ............................................................................................................................ 158 The Traditional Way ................................................................................................................ 158 New Validation Controls ........................................................................................................ 161 RequiredFieldValidator ......................................................................................... 161 CompareValidator ................................................................................................. 166 Contents RangeValidator ...................................................................................................... 168 Summary .................................................................................................................................. 170 11. FILE HANDLING AND COOKIES .................... 171 Introduction ............................................................................................................................. 172 Creating and Closing a File .................................................................................................... 172 Writing to a new file ............................................................................................................... 173 Appending Data to a File ....................................................................................................... 175 Reading a File .......................................................................................................................... 177 Cookies ..................................................................................................................................... 179 Creating a Cookie .................................................................................................................... 179 Viewing a Cookie .................................................................................................................... 181 Summary .................................................................................................................................. 183 12. DATABASES AND THE DATAGRID ................ 185 Introduction ............................................................................................................................. 186 What is ADO.NET? ................................................................................................................... 186 Importing ADO.NET ................................................................................................................ 186 The ADO.NET Objects .............................................................................................................. 187 Connection Object ................................................................................................. 187 Command Object ................................................................................................... 189 DataAdaptor Object.. ............................................................................................. 190 DataSet Object ....................................................................................................... 191 Displaying Data ....................................................................................................................... 192 Creating Our Access Database ............................................................................................... 193 Displaying Database Records ................................................................................................ 194 DataGrid Properties ................................................................................................................ 196 DataGrid Columns ...................................................................................................................2 00 DataGrid Buttons ....................................................................................................................2 02 DataGrid Paging ......................................................................................................................2 09 Summary ..................................................................................................................................2 13 13. INTERACTING WITH DATABASES ................. 215 Introduction .............................................................................................................................2 16 Adding Records ....................................................................................................................... 216 Updating Records ...................................................................................................................2 20 Deleting Records .....................................................................................................................2 25 Summary ..................................................................................................................................2 28 Essential ASP .NET fast 14. WHERE NEXT? ............................................ 229 Introduction ............................................................................................................................ 230 Microsoft ASP.NET .................................................................................................................. 230 4GuysFromRoila ...................................................................................................................... 230 ASP Alliance ............................................................................................................................. 231 Brinkster ...................................................................................................................................2 31 411 ASP.NET Directory ........................................................................................................... 231 LearnASP ..................................................................................................................................2 31 DotNetJunkies ......................................................................................................................... 232 And Finally ............................................................................................................................2 32 15. INDEX ......................................................... 233

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.