Mastering ASP. Net with VB. Net

Copyright © 2002 SYBEX Inc., 1151 Marina Village Parkway, Alameda, CA 94501. World rights reserved. The author(s) created reusable code in this publication expressly for reuse by readers. Sybex grants readers limited permission to reuse the code found in this publication or its accompanying CD - ROM so long as the author is attributed in any applicat ion containing the reusabe code and the code itself is never distributed, posted online by electronic transmission, sold, or commercially exploited as a stand- alone product. Aside from this specific exception concerning reusable code, no part of this publication may be stored in a retrieval system, transmitted, or reproduced in any way, including but not limited to photocopy, photograph, magnetic, or other record, without the prior agreement and written permission of the publisher.

pdf758 trang | Chia sẻ: banmai | Lượt xem: 2590 | Lượt tải: 0download
Bạn đang xem trước 20 trang tài liệu Mastering ASP. Net with VB. Net, để xem tài liệu hoàn chỉnh bạn click vào nút DOWNLOAD ở trên
pt executes the first statement. If the expression evaluates to false, JScript executes the second statement. The syntax is expression ? statement1 : statement2. Decrement (—) Decrements a value by 1. There are several syntax variations. —variable decrements a variable before an operation. variable— decrements a variable after an operation var = —variable delete Deletes a property or an array element. Division Assignment (/=) Divides a variable on the left side of the operator by a value on the right side and assigns the Operator Description result to the variable on the left side. Division (/) Divides two numbers. Equality (==) Tests for equality between two values or expressions. One of the most common errors made by VB.NET programmers is forgetting to use two equal (==) signs to test for equality. Greater than (>) Compares the relative size of two numeric values or expressions. Returns true if the value of the expression on the left side of the operator is larger than the value of the expression on the right side. Greater than or equal to (>=) Compares the relative size of two values or expressions. Returns true if the value of the expression on the left side of the operator is larger than or equal to the value of the expression on the right side. Identity (===) Compares two variables containing object references and returns true if both variables refer to the same object. Increment (++) Increments a value by 1. Inequality (!=) Compares two values or expressions for non- equality (read the operator as "not equal"). Operations using the inequality operator evaluate to true if the value on the left side of the operator is not equal to the value on the right side. instanceOf Returns true if the object is an instance of the specified class argument. Left Shift Assignment (<<=) Shifts the bits of a value Operator Description on the right side of the operator one position to the left, and assigns the result to a variable on the left. Left Shift (<<) Shifts the bits of a value one position to the left. Less than (<) Compares the relative size of two numeric values or expressions. Returns true if the value of the expression on the left side of the operator is smaller than the value of the expression on the right side. Less than or equal to (<=) Compares the relative size of two values or expressions. Returns true if the value of the expression on the left side of the operator is less than or equal to the value of the expression on the right side. Logical AND (&&) Performs a Boolean AND operation. Logical NOT (!) Performs a Boolean NOT operation. Logical OR (||) Performs a Boolean OR operation. Modulus Assignment (%=) Performs modulo arithmetic (returns the remainder of a division operation) between a variable on the left side of the operator and a value on the right side, and assigns the result to the variable on the left side. Modulus (%) Performs modulo arithmetic (returns the remainder of a division operation). Multiplication (*) Multiplies numeric values. new Creates a new object variable. Nonidentity (!==) Returns true if the operand on the left side Operator Description of the operator does not refer to the same object as the operand on the _right side. Right Shift Assignment (>>=) Shifts the bits of a value on the right side of the operator one position to the right and assigns the result to a variable on _the left. Right Shift (<<) Shifts the bits of a value one position to the right. Subtraction Assignment (-=) Subtracts a variable on the left side of the operator by a value on the right side and assigns the results to the variable on the left side. Subtraction (-) Subtracts numeric values. typeof Returns the type of an object or expression as a string. The return value is number, String, Boolean, Object, Function, or undefined. Unary Negation (-) Negates a value or expression. Unsigned Right Shift Assignment (>>>=) Shifts the bit pattern of a value on the right side of the operator to the right, zero-fills the bits on the left, and assigns the results to a variable on the left side of the operator. Unsigned Right Shift (>>>) Shifts the bit pattern of a value to the right and zero-fills the bits on the left. void Used to evaluate an expression. The void operator returns the value undefined. JScript Microsoft-Specific Extensions The features listed in this table are not ECMA compatible; they work only with Microsoft JScript. Extension Type Description Array operations The array methods concat, slice, dimensions, getItem, lbound, toArray, ubound, the VBArray object. Conditional compilation Use in situations where non-Microsoft browsers or servers may not be able to compile the code. You begin conditional compilation using the @cc_on statement or the @if or @set statements. See the "Conditional Compilation Variables" entry in the table under "JScript Operators" in this appendix for a full list. Control Flow do...while, Labeled, switch. Dates and Time getVarDate. Enumeration Enumerator, atEnd, item, moveFirst, moveNext. Error Handling Error object, description, number, throw, try…catch. Function Creation caller. Operators Identity (===), nonidentity (!==). Objects Enumerator, RegExp, Regular Expression, VBArray, ActiveXObject, GetObject. Regular Expressions and Pattern Matching RegExp, index, input, lastIndex, $1…$9, source, compile, exec, test, Regular Expression syntax. Script Engine Identification ScriptEngine, ScriptEngineBuildVersi on, ScriptEngineMajorVers ion, ScriptEngineMinorVers ion. Extension Type Description Strings The String methods concat, slice, match, replace, search, anchor, big, blink, bold, fixed, fontcolor, fontsize, italics, link, small, strike, sub, sup. JScript Constants This section contains a list of JScript compile-time error numbers and messages, arranged alphabetically by message. Error Number Description 5029 Array length must be a finite positive integer. 5030 Array length must be assigned a finite positive number. 5028 Array or arguments object expected. 5010 Boolean expected. 5003 Cannot assign to a function result. 5000 Cannot assign to 'this'. 5006 Date object expected. 5015 Enumerator object expected. 5022 Exception thrown and not caught. 5020 Expected Error Number Description ')' in regular expression. 5019 Expected ']' in regular expression. 5023 Function does not have a valid prototype object. 5002 Function expected. 5008 Illegal assignment. 5021 Invalid range in character set. 5014 JScript object expected. 5001 Number expected. 5007 Object expected. 5012 Object member expected. 5016 Regular Expression object expected. 5005 String expected. 5017 Syntax error in regular expression. 5026 The number of fractional digits is out of range. 5027 The precision is out of range. 5025 The URI to be decoded Error Number Description is not a valid encoding. 5024 The URI to be encoded contains an invalid character. 5009 Undefined identifier. 5018 Unexpected quantifier. 5013 VBArray expected. JScript Runtime Error Constants This section contains a list of JScript runtime error constants, arranged in numerical order. Error Number Description 5 Invalid procedure call or argument. 6 Overflow. 7 Out of memory. 9 Subscript out of range. 10 This array is fixed or temporarily locked. 11 Division by zero. 13 Type mismatch. 14 Out of string space. 17 Can't perform requested operation. 28 Out of stack space. 35 Sub or Function not defined. Error Number Description 48 Error in loading DLL. 51 Internal error. 52 Bad filename or number. 53 File not found. 54 Bad file mode. 55 File already open. 57 Device I/O error. 58 File already exists. 61 Disk full. 62 Input past end of file. 67 Too many files. 68 Device unavailable. 70 Permission denied. 71 Disk not ready. 74 Can't rename with different drive. 75 Path/File access error. 76 Path not found. 91 Object variable or With block variable not set. 92 For loop not initialized. 94 Invalid use Error Number Description of Null. 322 Can't create necessary temporary file. 424 Object required. 429 Automation server can't create object. 430 Class doesn't support Automation. 432 Filename or class name not found during Automation operation. 438 Object doesn't support this property or method. 440 Automation error. 445 Object doesn't support this action. 446 Object doesn't support named arguments. 447 Object doesn't support current locale setting. 448 Named argument not found. 449 Argument not optional. 450 Wrong Error Number Description number of arguments or invalid property assignment. 451 Object not a collection. 453 Specified DLL function not found. 458 Variable uses an Automation type not supported in JScript. 462 The remote server machine does not exist or is unavailable. 501 Cannot assign to variable. 502 Object not safe for scripting. 503 Object not safe for initializing. 504 Object not safe for creating. 507 An exception occurred. 5000 Cannot assign to 'this'. 5001 Number expected. 5002 Function expected. 5003 Cannot assign to a function result. 5004 Cannot Error Number Description index object. 5005 String expected. 5006 Date object expected. 5007 Object expected. 5008 Illegal assignment. 5009 Undefined identifier. 5010 Boolean expected. 5011 Can't execute code from a freed script. 5012 Object member expected. 5013 VBArray expected. 5014 JScript object expected. 5015 Enumerator object expected. 5016 Regular Expression object expected. 5017 Syntax error in regular expression. 5018 Unexpected quantifier. 5019 Expected ']' in regular expression. 5020 Expected ')' in regular expression. 5021 Invalid range in Error Number Description character set. 5022 Exception thrown and not caught. 5023 Function does not have a valid prototype object. 5024 The URI to be encoded contains an invalid character. 5025 The URI to be decoded is not a valid encoding. 5026 The number of fractional digits is out of range. 5027 The precision is out of range. 5028 Array or arguments object expected. 5029 Array length must be a finite positive integer. 5030 Array length must be assigned a finite positive number. JScript Syntax Error Constants This section contains a list of JScript syntax error constants, arranged numerically. Error Number Description 1001 Out of memory. 1002 Syntax error. Error Number Description 1003 Expected ':'. 1004 Expected ';'. 1005 Expected '('. 1006 Expected ')'. 1007 Expected ']'. 1008 Expected '{'. 1009 Expected '}'. 1010 Expected identifier. 1011 Expected '='. 1012 Expected '/'. 1013 Invalid number. 1014 Invalid character. 1015 Unterminated string constant. 1016 Unterminated comment. 1018 'return' statement outside of function. 1019 Can't have 'break' outside of loop. 1020 Can't have 'continue' outside of loop. 1023 Expected hexadecimal digit. 1024 Expected 'while'. 1025 Label redefined. 1026 Label not Error Number Description found. 1027 'default' can only appear in a 'switch' statement. 1028 Expected identifier or string. 1029 Expected '@end'. 1030 Conditional compilation turned off. 1031 Expected constant. 1032 Expected '@'. 1033 Expected 'catch'. 1034 Expected 'var'. 1035 'throw' must be followed by an expression on the same source line. 1019 Can't have 'break' outside of loop. 1020 Can't have 'continue' outside of loop. 1030 Conditional compilation is turned off. 1027 'default' can only appear once in a 'switch' statement. 1005 Expected '('. 1006 Expected ')'. 1012 Expected '/'. Error Number Description 1003 Expected ':'. 1004 Expected ';'. 1032 Expected '@'. 1029 Expected '@end'. 1007 Expected ']'. 1008 Expected '{'. 1009 Expected '}'. 1011 Expected '='. 1033 Expected 'catch'. 1031 Expected constant. 1023 Expected hexadecimal digit. 1010 Expected identifier. 1028 Expected identifier, string, or number. 1024 Expected 'while'. 1014 Invalid character. 1026 Label not found. 1025 Label redefined. 1018 'return' statement outside of function. 1002 Syntax error. 1035 Throw must be followed by an expression on the same source line. Error Number Description 1016 Unterminated comment. 1015 Unterminated string constant. JScript Feature Availability, by Version Because JScript has evolved over time, the different versions available in the various releases of Internet Explorer support different feature sets. This table shows the features available by IE version. IE Version JScript Feature 1 2 3 4 5 5.5 0…n Property X $1...$9 Properties X abs Method X acos Method X ActiveXObject Object X Addition Operator (+) X anchor Method X apply method X arguments Property X Array Object X asin Method X Assignment Operator (=) X atan Method X atan2 Method X atEnd Method X big Method X Bitwise AND Operator (&) X Bitwise Left Shift Operator (<<) X Bitwise NOT Operator (~) X Bitwise OR Operator (|) X Bitwise Right Shift Operator (>>) X Bitwise XOR Operator (^) X blink Method X IE Version JScript Feature 1 2 3 4 5 5.5 bold Method X Boolean Object X break Statement X call method X IE Version JScript Feature 1 2 3 4 5 5.5 callee Property X caller Property X catch Statement X @cc_on Statement X ceil Method X charAt Method X charCodeAt Method X Comma Operator (,) X // (Single-line Comment Statement) X /*..*/ (Multiline Comment Statement) X Comparison Operators X compile Method X concat Method (Array) X concat Method (String) X Conditional Compilation X Conditional Compilation Variables X Conditional (ternary) Operator (?:) X constructor Property X continue Statement X cos Method X Data Type Conversion X Date Object X decodeURI Method X decodeURIComponent X Decrement Operator ( — ) X IE Version JScript Feature 1 2 3 4 5 5.5 delete Operator X description Property X IE Version JScript Feature 1 2 3 4 5 5.5 dimensions Method X Division Operator (/) X do...while Statement X E Property X encodeURI Method X encodeURI Component X Enumerator Object X Equality Operator (==) X Error Object X escape Method X eval Method X eXec Method X eXp Method X fiXed Method X floor Method X fontcolor Method X fontsize Method X for Statement X for...in Statement X fromCharCode Method X Function Object X function Statement X getDate Method X getDay Method X getFullYear Method X getHours Method X getItem Method X IE Version IE Version JScript Feature 1 2 3 4 5 5.5 JScript Feature 1 2 3 4 5 5.5 getMilliseconds Method X getMinutes Method X getMonth Method X GetObject Function X getSeconds Method X getTime Method X getTimezoneOffset Method X getUTCDate Method X getUTCDay Method X getUTCFullYear Method X getUTCHours Method X getUTCMilliseconds Method X getUTCMinutes Method X getUTCMonth Method X getUTCSeconds Method X getVarDate Method X getYear Method X Global Object X global Property X Greater than Operator (>) X Greater than or equal to Operator (>=) X hasOwnProperty Method X Identity Operator (===) X @if Statement X if...else Statement X ignoreCase Property X Increment Operator (++) X IE Version JScript Feature 1 2 3 4 5 5.5 indeX Property X indeXOf Method X IE Version JScript Feature 1 2 3 4 5 5.5 Inequality Operator (!=) X Infinity Property X input Property X instanceof Operator X isFinite Method X isNaN Method X isPrototypeOf Method X italics Method X item Method X join Method X Labeled Statement X lastIndeX Property X lastIndeXOf Method X lastMatch Property X lastParen Property X lbound Method X leftConteXt Property X length Property (Arguments) X length Property (Array) X length Property (Function) X length Property (String) X Less than Operator (<) X Less than or equal to Operator (<=) X link Method X LN2 Property X IE Version JScript Feature 1 2 3 4 5 5.5 LN10 Property X localeCompare Method X log Method X LOG2E Property X LOG10E Property X IE Version JScript Feature 1 2 3 4 5 5.5 Logical AND Operator (&&) X Logical NOT Operator (!) X Logical OR Operator (||) X match Method X Math Object X maX Method X MAX_VALUE Property X message Property X min Method X MIN_VALUE Property X Modulus Operator (%) X moveFirst Method X moveNeXt Method X multiline Property X Multiplication Operator (*) X name Property X NaN Property (Global) X NaN Property (Number) X NEGATIVE_INFINITY Property X new Operator X Nonidentity Operator (!==) X Number Object X IE Version JScript Feature 1 2 3 4 5 5.5 number Property X Object Object X Operator Precedence X parse Method X parseFloat Method X parseInt Method X PI Property X IE Version JScript Feature 1 2 3 4 5 5.5 pop Method X POSITIVE_INFINITY Property X pow Method X prototype Property X propertyIsEnumeramble Property X push Method X random Method X RegEXp Object X Regular EXpression Object X Regular EXpression SyntaX X replace Method X return Statement X reverse Method X rightConteXt Property X round Method X ScriptEngine Function X ScriptEngineBuildVersion Function X ScriptEngineMajorVersion Function X ScriptEngineMinorVersion Function X search Method X IE Version JScript Feature 1 2 3 4 5 5.5 @set Statement X setDate Method X setFullYear Method X setHours Method X setMilliseconds Method X setMinutes Method X setMonth Method X setSeconds Method X IE Version JScript Feature 1 2 3 4 5 5.5 setTime Method X setUTCDate Method X setUTCFullYear Method X setUTCHours Method X setUTCMilliseconds Method X setUTCMinutes Method X setUTCMonth Method X setUTCSeconds Method X setYear Method X shift Method X sin Method X slice Method (Array) X slice Method (String) X small Method X sort Method X source Property X splice Method X split Method X sqrt Method X IE Version JScript Feature 1 2 3 4 5 5.5 SQRT1_2 Property X SQRT2 Property X strike Method X String Object X sub Method X substr Method X substring Method X Subtraction Operator (-) X sup Method X switch Statement X tan Method X IE Version JScript Feature 1 2 3 4 5 5.5 test Method X this Statement X throw Statement X toArray Method X toDateString Method X toEXponential Method X toFiXed Method X toGMTString Method X toLocaleDateString Method X toLocaleLowercase Method X toLocaleString Method X toLocaleTimeString Method X toLocaleUppercase Method X toLowerCase Method X toPrecision Method X toString Method X IE Version JScript Feature 1 2 3 4 5 5.5 toTimeString Method X toUpperCase Method X toUTCString Method X try Statement X typeof Operator X ubound Method X Unary Negation Operator (-) X undefined Property X unescape Method X unshift Method X Unsigned Right Shift Operator (>>>) X UTC Method X valueOf Method X IE Version JScript Feature 1 2 3 4 5 5.5 var Statement X VBArray Object X void Operator X while Statement X with Statement X List of Figures Chapter 2: HTML Basics Figure 2.1: Hello World file (HelloWorld.htm) Figure 2.2: HTML Is Easy (ch2l1.htm) Figure 2.3: List styles (ch2-2.htm) Figure 2.4: Nested lists (ch2-3.htm) Figure 2.5: Explicit line breaks (ch2-4.htm) Figure 2.6: Six HTML heading levels (ch2-5.htm) Figure 2.7: Div and span experiments (ch2-6.htm) Figure 2.8: Default image alignment (ch2-8.htm) Figure 2.9: Right-aligned image (ch2-9.htm) Figure 2.10: In-line images (ch2-10.htm) Figure 2.11: Background image Figure 2.12: A menu page with several sections (ch2-12.htm) Figure 2.13: Multiple-choice question screen (ch2-13a.htm) Figure 2.14: Feedback for a multiple-choice question Figure 2.15: Simple HTML table (ch2-14.htm) Figure 2.16: Simple table with borders (ch2-15.htm) Figure 2.17: Table using colspan and rowspan attributes (ch2-16.htm) Figure 2.18: Nested framesets (ch2-18a.htm–ch2-18d.htm) Figure 2.19: Absolute and relative positioning (ch2-21.htm) Figure 2.20: Controlling element position with tables (ch2-22.htm) Figure 2.21: Text without style sheet applied (ch2-24.htm) Figure 2.22: Text with style sheet applied (ch2-24.htm) Chapter 4: Introduction to ASP.NET Figure 4.1: ASP.NET integration with the .NET framework Figure 4.2: VS.NET New Project window Figure 4.3: Solution Explorer pane containing a new project Figure 4.4: Solution Explorer pane after creating the ch4 folder Figure 4.5: DOCUMENT Property Pages dialog Figure 4.6: The DynamicImage.aspx Web Form after placing controls Figure 4.7: The DynamicImage.aspx Web Form before posting Figure 4.8: The DynamicImage.aspx Web Form after posting Chapter 5: Introduction to Web Forms Figure 5.1: Visual Studio New Project dialog: Create a VB.NET Web application Figure 5.2: A simple login page Figure 5.3: Simple login page with RequiredFieldValidators Figure 5.4: RegularExpressionValidator control example Chapter 6: Introduction to the System.Web Namespace Figure 6.1: The error message displayed for a null object reference Figure 6.2: A simple Web Form to illustrate the ShoppingCart class methods Figure 6.3: ASPSessionID display example Figure 6.4: A Web Form with several input controls Chapter 7: The SessionState Object Figure 7.1: Cookie options available through the Internet Explorer Security Settings dialog Figure 7.2: Cookie options available through the Netscape 6 Preferences dialog Figure 7.3: Cookie options available through the Internet Explorer 6 (beta) Internet Options Privacy dialog Figure 7.4: The ASPSessionID cookie appears in the browser address field when you set the session state cookieless attribute to "true." Figure 7.5: Visual Studio Web Form design surface after adding a HyperLink server control Figure 7.6: Session ("counter") and Session("guid") values shown in a browser Figure 7.7: The VS.NET View menu Figure 7.8: The VS.NET Server Explorer window Figure 7.9: Server Explorer view of the Northwind database tables Figure 7.10: DataGrid control filled with data from the Customers table in the sample Northwind database Figure 7.11: VS.NET DataGrid Auto Format dialog Figure 7.12: DataGrid control with Auto Format setting (filled with data from the Customers table in the sample Northwind database) Figure 7.13: The Windows 2000 Performance application at startup Figure 7.14: The Performance application's Add Counters dialog Figure 7.15: The Add Counters dialog set to monitor anonymous requests per second for the ASP.NET VBNetWeb application Figure 7.16: Starting the ASP.NET state service from the Services dialog Chapter 8: The HttpServerUtility Object Figure 8.1: Result of running the ch8-2.aspx Web Form with the Server.Transfer command enabled Figure 8.2: Output of simple example file showing the difference between the #INCLUDE command and the Server.Execute and Server.Transfer methods Figure 8.3: Simple Server.HtmlEncode method call example Figure 8.4: A Web Form that displays its own code Figure 8.5: Clicking the anchor tag in the leftmost browser causes the second browser to appear and display the message. Chapter 9: Debugging ASP.NET and Error-Handling Figure 9.1: Select the project compilation mode from the toolbar. Figure 9.2: The Configuration Manager dialog Figure 9.3: Configuration Properties dialog Figure 9.4: Enable ASP.NET debugging in the Project Property Pages dialog. Figure 9.5: The Breakpoint Properties dialog Figure 9.6: The Breakpoint Condition dialog Figure 9.7: The Breakpoint Condition dialog Figure 9.8: Trace output with tracing enabled in the web.config file (screen 1) Figure 9.9: Trace output with tracing enabled in the web.config file (screen 2) Figure 9.10: Trace output with tracing enabled in the web.config file (screen 3) Figure 9.11: Trace output with tracing enabled in the web.config file (screen 4) Figure 9.12: Viewing trace output via the trace.axd HttpHandler Figure 9.13: Trace output with explicit Trace.Write results (screen 1) Figure 9.14: Trace output with explicit Trace.Write results (screen 2) Figure 9.15: OverflowException error message Figure 9.16: The ch9-4.aspx Web Form after searching with a valid search term Figure 9.17: The ch9-4.aspx Web Form error display afterr searching with a valid search term Figure 9.18: ASP.NET error display for a missing custom error file Figure 9.19: Custom HTML error display file Chapter 10: File and Event Log Access with ASP.NET Figure 10.1: Example Web Form ch10-1.aspx after setting the last access date Figure 10.2: Directory listing: output from the ch10-4.aspx Web Form Figure 10.3: Directory listing: output from the ch10-4.aspx Web Form Figure 10.4: Custom HTML versus HtmlTextWriter: two table examples Figure 10.5: The IE 6 File Download dialog Figure 10.6: The background IE 6 File Download dialog (progress dialog) Figure 10.7: Downloading files using various controls Figure 10.8: Uploading files: the file field control Figure 10.9: Uploading files: information available on the server from the HtmlFileInput control Chapter 11: Sending and Receiving Messages with ASP.NET Figure 11.1: DirectoryWatcherService project in Design mode after clicking the Add Installer link Figure 11.2: VS.NET debugger Processes dialog Figure 11.3: VS.NET debugger Attach to Process dialog Figure 11.4: The IIS Default Web Site Properties dialog Figure 11.5: The extended log format dialog for the W3C Extended Log format Figure 11.6: IIS Extended Logging Properties dialog for the W3C extended log format Figure 11.7: Form to send an email message Figure 11.8: Output from the ch11-4.aspx Web Form Figure 11.9: Output from the ch11-5.aspx Web Form using the getfiles method from the class ch11_4 Chapter 12: Introduction to Relational Databases and SQL Figure 12.1: Teachers-to-students relationship query Chapter 13: Introduction to ADO.NET Figure 13.1: The Web Form ch13-1 lets you build and test simple connections. Figure 13.2: Web Form ch13-1 after building a successful connection Figure 13.3: The Connect To SQL Server dialog Figure 13.4: The Trace Properties dialog Figure 13.5: The Trace Properties dialog Events tab, with default event class selections Figure 13.6: The trace log set to audit login information Figure 13.7: Simple Recordset object Figure 13.8: Shaped recordset where each customer record has a chapter column consisting of another recordset containing multiple orders for that customer Figure 13.9: Initial DataReader state Figure 13.10: Results from Listing 13.4 in Internet Explorer Chapter 14: Accessing Data Figure 14.1: SQL Query Analyzer Toolbar with Object Browser button pressed Figure 14.2: SQL Query Analyzer with Object Browser pressed Figure 14.3: SQL Query Analyzer New dialog Figure 14.4: SQL Query Analyzer New dialog, template selection Figure 14.5: SQL Server Enterprise Manager Stored Procedure Properties dialog Figure 14.6: Testing a parameterized stored procedure in the Query Analyzer Figure 14.7: The ch14-3.aspx Web Form running in a browser Figure 14.8: The Web Form ch14-4.aspx contains a modified version for selecting students of a specific teacher. Figure 14.9: DataList with an ItemTemplate applied Figure 14.10: The list of students from the Web Form ch14-7.aspx Figure 14.11: SQL Server's Create Database Diagram Wizard opened on the ClassRecords database Figure 14.12: Database diagram for the Students, TeacherStudent, and StudentClass tables Figure 14.13: The Web Form ch14-8.aspx: editing a student name Figure 14.14: The Web Form ch14-9.aspx lets a user edit, delete, and insert students. Figure 14.15: The Web Form ch14-9.aspx lets a user edit, delete, and insert students. Chapter 15: Using XML in Web Applications Figure 15.1: The flexible.xml file in IE displayed with the default stylesheet Figure 15.2: Result from transforming flexible.xml using the XSLT stylesheet flexible.xsl Figure 15.3: The Select XML File property dialog Figure 15.4: The Web Form ch15-2.aspx uses an XmlTextReader to display node values from the flexible.xml file. Figure 15.5: The Generate Dataset dialog Figure 15.6: Formatted contents of the ch15_dsClassRecords_Students1 dataset. Chapter 16: Introduction to VB.NET Web Applications Figure 16.1: IIS Default Web Site properties dialog Figure 16.2: Virtual Directory Creation Wizard Figure 16.3: Virtual Directory Creation Wizard, Virtual Directory Alias screen Figure 16.4: Virtual Directory Creation Wizard, Wed Site Content Directory screen Figure 16.5: Virtual Directory Creation Wizard, Access Permissions screen Figure 16.6: Internet Information Services applet after creating the VBNetWebTest virtual directory Figure 16.7: VBNetWebTest Propert ies dialog Figure 16.8: VBNetWebTest Properties, Application Configuration dialog Figure 16.9: Component Services applet, COM+ applications Figure 16.10: Component Services applet, COM+ application pop-up menu Figure 16.11: Nested configuration file error Figure 16.12: Test hierarchical web.config files—read application settings Figure 16.13: Output from the Web Form VBNetWebTest.getProducts.aspx Figure 16.14: Output from the Web Form VBNetWebTest.addProduct.aspx after adding a custom setting Chapter 17: State Maintenance and Cacheing Figure 17.1: The first page of the CookieSequence Web Form sequence Figure 17.2: The FileSequencer object writes an XML file containing the sequence, the current sequence index, and the data entered by the user. Figure 17.3: The Web Form cacheExample1.aspx displays the text "Reading from file." whenever the cache is refreshed. Figure 17.4: The Web Form cacheExample1.aspx displays the text "Read from cache." when the cache is current. Figure 17.5: The Web Form cacheExample1.aspx displays the text "Reading from file." after refreshing the cache. Chapter 18: Controlling Access and Monitoring Figure 18.1: IIS Authentication Methods dialog Figure 18.2: Enter Network Password dialog Figure 18.3: Access denied page Figure 18.4: Netscape 4 Username And Password Required dialog Figure 18.5: Initial request for the Web Form ch18-1.aspx. Request denied; browser displays login dialog. Figure 18.6: User entered vaild username/password combination Figure 18.7: Custom Authentication form before successful authentication Figure 18.8: Custom authentication form after successful authentication Figure 18.9: Custom authentication form after attempting to authenticate more than once Figure 18.10: IIS Certificate Wizard options Figure 18.11: IIS Certificate Wizard, Delayed Or Immediate Request screen Figure 18.12: IIS Certificate Wizard, Name And Security Settings screen Figure 18.13: IIS Certificate Wizard, Certificate Request File Name screen. Figure 18.14: IIS Certificate Wizard, Pending Certificate Request screen Chapter 20: Leveraging Browser Clients Figure 20.1: If you don't "break up" the tag when you write script with inline code, you'll get a spurious error. Figure 20.2: VBScript message boxes are more flexible than JavaScript alerts. Figure 20.3: First special offer from the Web Form ch20-5.aspx Figure 20.4: Second special offer from the Web Form ch20-5.aspx Figure 20.5: Predefined frameset templates Figure 20.6: Horizontal split frameset template Figure 20.7: The ActiveX Label control lets you display angled text on the page. Chapter 21: Web Services Figure 21.1: Web Service Description page generated automatically by VS.NET Figure 21.2: Test Web Method Operation page generated automatically by VS.NET Figure 21.3: VS-generated sample GET request and response for the getPayment Web method Figure 21.4: XML response from the GET request for the getPayment Web method Figure 21.5: VS-generated sample POST request and response for the getPayment Web method Figure 21.6: VS-generated sample SOAP request for the getPayment Web method Figure 21.7: VS-generated sample SOAP response for the getPayment Web method Figure 21.8: Partial view of the ch21_payment WSDL XML document in IE Figure 21.9: The Mortgage Calculator Web Service interface Figure 21.10: The Mortgage Payment response after executing successfully Figure 21.11: The Mortgage Payment Windows Form application interface Figure 21.12: The Add Web Reference Wizard Figure 21.13: The VBNetWeb ch21-payment.asmx Web Service in the Add Web Reference Wizard dialog Chapter 22: Web Services, COM Components, and the SOAP Toolkit Figure 22.1: VB6 Mortgage Calculator client application interface Figure 22.2: The initialization form acts as a splash screen and initializes the SOAP client. Chapter 23: Build Your Own Web Controls Figure 23.1: Wed Form designer surface with pretty.XML.ascx User Control Figure 23.2: The labeled TextBox Custom Control default interface Figure 23.3: The Customize Toolbox dialog Figure 23.4: LabeledTextBox Composite Control with custom property settings Figure 23.5: DateTable Custom Control default UI characteristics Figure 23.6: DateTable Custom Control Properties Window Figure 23.7: DateTable Custom Control after setting design-time properties Figure 23.8: Automatic Property error dialog List of Tables Chapter 2: HTML Basics Table 2.1: Table Alignment Attributes Chapter 4: Introduction to ASP.NET Table 4.1: Comparison of Classic ASP and ASP.NET Chapter 5: Introduction to Web Forms Table 5.1: ASP.NET Server Input Controls Chapter 6: Introduction to the System.Web Namespace Table 6.1: Request.ServerVariables Keys and Values Table 6.2: The HttpBrowserCapabilities Object's Properties Table 6.3: The HttpClientCertificate Object's Properties Chapter 8: The HttpServerUtility Object Table 8.1: Appropriate uses for #INCLUDE, Server.Transfer, and Server.Execute Chapter 9: Debugging ASP.NET and Error-Handling Table 9.1: ASP.NET Application-Level Events Table 9.2: Properties and Methods of the Base Exception Object Table 9.3: HTTP Status Codes Chapter 10: File and Event Log Access with ASP.NET Table 10.1: System.IO.File Class Static Methods Table 10.2: StreamWriter and BinaryWriter Write Method Parameters Chapter 11: Sending and Receiving Messages with ASP.NET Table 11.1: Standard Date/Time Formats (from the MSDN .NET Documentation) Table 11.2: DateTime Custom Formatting Patterns (from the MSDN .NET Documentation) Chapter 12: Introduction to Relational Databases and SQL Table 12.1: Sample Class Records: Students Table 12.2: Sample Class Records: Students Table 12.3: Sample Class Records: Teachers Table 12.4: Teachers-to-Students Relationship Query Result Table 12.5: Count of Students by Teacher Chapter 13: Introduction to ADO.NET Table 13.1: CommandBehavior Enumeration Options Chapter 14: Accessing Data Table 14.1: XML Tags that Define the Template Types Chapter 17: State Maintenance and Cacheing Table 17.1: The Cache object's Add method parameters Table 17.2: Property and method names for the HttpCachePolicy class and their equivalent OutputCache directive attributes Chapter 18: Controlling Access and Monitoring Table 18.1: Optional attributes that can be added to the element List of Listings Chapter 2: HTML Basics Listing 2.1: HTML Is Easy (ch2-1.htm) Listing 2.2: Explicit line breaks (ch2-4.htm) Listing 2.3: Div and span experiments (ch2-6.htm) Listing 2.4: Sample formatted HTML page (ch2-7.htm) Listing 2.5: A menu page with several sections (ch2-12.htm) Listing 2.6: A set of linked pages (ch2-13a.htm–ch2-13e.htm) Listing 2.7: Client-side image map example (ch2-19a.htm) Listing 2.8: Nested framesets (ch2-18a.htm–ch2-18d.htm) Listing 2.9: Controlling the z-order position (ch2-20.htm) Listing 2.10: Absolute and relative positioning (ch2-21.htm) Listing 2.11: Controlling element position with transparent images (ch2-23.htm) Listing 2.12: Cascading style sheet example (ch2-24.htm) Chapter 4: Introduction to ASP.NET Listing 4.1: Classic ASP embedded code (ch4-1.aspx) Listing 4.2: Code behind a Web Form example (ch4-2.aspx.vb) Listing 4.3: The DynamicImage Page_Load event code (DynamicImage.vb) Listing 4.4: The getImage function (DynamicImage.vb) Chapter 5: Introduction to Web Forms Listing 5.1: Create a Web Form with Notepad (notepadForm.aspx) Listing 5.2: HTML code for login form (ch5-1.aspx) Listing 5.3: HTML code for login form with RequiredFieldValidator (ch5-2.aspx) Listing 5.4: Web Form Load event with server-side validation (ch5-3.aspx) Chapter 6: Introduction to the System.Web Namespace Listing 6.1: Testing whether a cookie key exists (ch6-1.aspx.vb) Listing 6.2: Alternate test whether a cookie key exists (ch6-1.aspx.vb) Listing 6.3: Creating a cookie containing multiple values (ch6-1.aspx.vb) Listing 6.4: Displaying a cookie that contains multiple values (ch6-1. aspx.vb) Listing 6.5: The cookie-based ShoppingCart class (ShoppingCart.aspx.vb) Listing 6.6: Web Form UI methods to add and remove items from the ShoppingCart (ch6-2.aspx) Listing 6.7: Alternate ways to implement the AddToCart method (ShoppingCart.aspx.vb) Listing 6.8: Displaying all cookie keys and values (ch6-3.aspx.vb) Listing 6.9: A Web Form with several input controls (ch6-5.aspx) Listing 6.10: An example of buffered versus unbuffered response (ch6-9.aspx.vb) Listing 6.11: Example of the Response.BinaryWrite method (ch6-12.aspx.vb) Listing 6.12: Storing a simple value in the Application object (ch6-13.aspx.vb) Listing 6.13: Working with collections at Application scope (ch6-14.aspx) Listing 6.14: The HttpApplication.BeginRequest event (global.aspx.vb) Listing 6.15: Application-level error-handling and logging example (ch6-16.aspx.vb, global.asax.vb) Listing 6.16: A custom web.config file for the ch6 folder (ch6\config.web) Chapter 7: The SessionState Object Listing 7.1: Create a new Session variable (ch7-2.aspx.vb) Listing 7.2: VB6 function to generate GUID values (ch7-VB6CGUIDMaker.cls) Listing 7.3: Altered GUIDMaker class that always returns a single, unchanging GUID value (GuidMaker.vb) Listing 7.4: Determining whether a Session variable exists (ch7-4.aspx.vb) Listing 7.5: Persist a DataSet in a Session variable (ch7-5.aspx.vb) Chapter 8: The HttpServerUtility Object Listing 8.1: Using the Server.CreateObject and Server.HtmlEncode methods (ch8- 1.aspx.vb) Listing 8.2: Simple example file showing the difference between the #INCLUDE command and the Server.Execute and Server.Transfer methods (ch8-2.aspx.vb) Listing 8.3: CSS class to formatting (ch8.css) Listing 8.4: This Web Form creates a footer and centers it near the bottom of the page (ch8-footer.aspx). Listing 8.5: Using the HtmlEncode method (ch8-5.aspx.vb) Listing 8.6: The Web Form ch8-6.aspx displays its own code-behind code or HTML in a Label control when you click one of the buttons on the form (ch8-6.aspx.vb). Listing 8.7: Using the Server.UrlEncode method (ch8-7 test.aspx.vb) Chapter 9: Debugging ASP.NET and Error-Handling Listing 9.1: Test a breakpoint condition (ch9-1.aspx.vb) Listing 9.2: Global.asax.vb file with all possible events implemented (Global.asax.vb) Listing 9.3: The InvalidSearchEntry custom exception class (InvalidSearchEntryException.vb) Listing 9.4: Clicking the Search button in the Web Form ch9-4.aspx raises an error if the search term contains spaces or capital letters. (ch9-4.aspx.vb) Chapter 10: File and Event Log Access with ASP.NET Listing 10.1: The showFileInfo subroutine retrieves and displays information about a file. (ch10-1.aspx.vb) Listing 10.2: Open and read a text file. (ch10-1.aspx.vb) Listing 10.3: Functional duplicate of ch10-1.aspx using the FileInfo class (ch10- 2.aspx.vb) Listing 10.4: StringBuilder versus StringWriter (ch10-3.aspx.vb) Listing 10.5: Using the Directory and DirectoryInfo classes (ch10-4.aspx.vb) Listing 10.6: Create table comparison: custom HTML versus HtmlTextWriter (ch10- 7.aspx.vb) Listing 10.7: HTML code for the ch10-8.aspx file (ch10-8.aspx) Listing 10.8: The Web Form ch10-10.aspx Page_Load event (ch10-10.aspx.vb) Chapter 11: Sending and Receiving Messages with ASP.NET Listing 11.1: The DirectoryWatcherService code (DirectoryWatcherService.vb) Listing 11.2: Report that shows all data collected by the DirectoryWatcher service (ch11-1.aspx.vb) Listing 11.3: Report that shows all data collected by the DirectoryWatcher service (ch11-2.aspx.vb) Chapter 13: Introduction to ADO.NET Listing 13.1: Code for the Web Form ch13-1 (ch13-1.aspx.vb) Listing 13.2: Code for the Web Form ch13-2 (ch13-2.aspx.vb) Listing 13.3: XML file containing customer-order-products data (ch13-3.xml) Listing 13.4: The Web Form ch13-4.aspx creates an OleDbDataReader and displays the data from the customers table (ch13-4.aspx.vb). Chapter 14: Accessing Data Listing 14.1: SQL Server 2000 Create Procedure Basic Template Listing 14.2: VS.NET autogenerated Connection and Command object code (ch14- 2.aspx.vb) Listing 14.3: A sample template (ch14-5ItemTemplate.ascx) Listing 14.4: The Web Form ch14-5.aspx uses an ItemTemplate to display student data from the ClassRecords database (ch14-5.aspx.vb). Listing 14.5: ItemTemplate code for the Repeater control in the Web Form ch14-7.aspx (ch14-7ItemTemplate.ascx) Listing 14.6: Using a transaction to perform multiple dependent database operations (ch14-7.aspx.vb) Listing 14.7: The Web Form ch14-8 lets you edit a student's name and updates the database with the new value (ch14-8.aspx.vb). Chapter 15: Using XML in Web Applications Listing 15.1: Simple XML file that holds INI file type information (XML-INI.xml) Listing 15.2: The XML document extends the INI file format (XML_INI2.xml) Listing 15.3: The flexible.xml XML file Listing 15.4: The flexible.xsl file creates an HTML ListBox containing the items from the flexible.xml file (flexible.xsl). Listing 15.5: The Web Form ch15-2.aspx uses an XmlTextReader to read the flexible.xml file (ch15-2.aspx.vb). Listing 15.6: Generated XSD schema for the ClassRecords Students table (ch15_ds ClassRecords_Students.xsd) Listing 15.7: Programmatic XSLT transform (ch15-5.aspx.vb) Chapter 16: Introduction to VB.NET Web Applications Listing 16.1: Test hierarchical unmodified web.config files (test.aspx.vb) Listing 16.2: Test hierarchical web.config files—read application settings (VBNetWebTest/test.aspx, VBNetWebTest/ClassRecords/test.aspx, VBNetWebTest/ClassRecords/Northwind/test.aspx) Listing 16.3: Retrieving custom configuration settings (getProducts.aspx.vb) Listing 16.4: Adding a custom configuration setting dynamically (addProduct.aspx.vb) Listing 16.5: The ProductsNameValueHandler custom configuration handler code (ProductsNameValueHandler.ProductInfoHandler.vb) Chapter 17: State Maintenance and Cacheing Listing 17.1: The CookieSequencer class manages the cookies required to force a ser to traverse a specific sequence of pages (CookieSequence.aspx.vb). Listing 17.2: Code for the CookieSequence1.aspx Web Form (CookieSequence1.aspx.vb) Listing 17.3: Code for the SessionSequencer class (SessionSequencer.vb) Listing 17.4: Page_Load event code for the Web Form SessionSequence1.aspx (SessionSequence1.aspx.vb) Listing 17.5: The FileSequencer class handles user sequencing (FileSequencer.vb). Listing 17.6: The Web Form CacheExample1.aspx creates a cached object with a file dependency (cacheExample1.aspx.vb). Listing 17.7: The Cache.Add and Insert methods perform differently (cacheExample2.aspx.vb). Chapter 18: Controlling Access and Monitoring Listing 18.1: Domain authentication with Basic authentication based on the LOGON_USER HTTP variable value (ch18-1.aspx.vb) Listing 18.2: The Web Form ch18-2 uses custom authentication (ch18-2.aspx.vb). Listing 18.3: The Web Form ch18-3.aspx displays a login form and authenticates users (ch18-3.aspx.vb). Listing 18.4: The Web Form ch18-5 creates and tags if they don't already exist (ch18-5.aspx.vb). Listing 18.5: The stored procedure ch18_countPage logs page requests to the ch18 table in the VBNetWeb database (VBNetWeb_ch18Table.sql). Listing 18.6: The stored procedure ch18_getPageCount returns the total number of requests for a specified URL (VBNetWeb_ch18Table.sql). Listing 18.7: The Ch18Counter class inserts data into a database table for each counted page and returns page counts (Ch18Counter.vb). Chapter 20: Leveraging Browser Clients Listing 20.1: Client-side script to display alerts (ch20-1.htm) Listing 20.2: Combining server and client tags (ch20-2.aspx) Listing 20.3: The code-behind file ch20-2.aspx.vb writes a client-side script. Listing 20.4: Transferring server-side variables to client-side scripts (ch20-3.aspx.vb) Listing 20.5: Obtaining the screen resolution of the client computer (ch20-4.aspx.vb) Listing 20.6: XML file containing the data for the special offers (SpecialOffers.xml) Listing 20.7: The Web Form ch20-5.aspx.vb creates one client-side script containing an array and creates a script reference to a separate file containing JavaScript (ch20- 5.aspx.vb). Listing 20.8: Referenced JScript file (SpecialOffers.js) Listing 20.9: The Web Form ch20-9.aspx uses a client-side XSLT transform to display the special offers (ch20-9.aspx). Listing 20.10: Using the document object (documentObject.htm) Listing 20.11: Changing paragraph contents with script (paragraphText.htm) Listing 20.12: Moving objects on-screen (scrollingText.htm) Listing 20.13: ActiveX control example for IE (angledText.htm) Listing 20.14: Communicating with client-side ActiveX controls (spinningText.htm) Listing 20.15: Creating client-side ActiveX objects with JScript (dictionaryExample.htm) Chapter 21: Web Services Listing 21.1: VS autogenerated code for the ch21-payment.asmx Web Service (ch21- payment.asmx.vb) Listing 21.2: The Mortgage Payment Calculator Web Service's getPayment method (ch21-payment.asmx.vb) Listing 21.3: The Mortgage Payment Calculator Web Service's totalPaymentAmount method (ch21-payment.asmx.vb) Listing 21.4: The WSDL document for the Mortgage Payment Calculator Web Service (ch21_payment.asmx) Listing 21.5: The JScript getPayment function calls the getPayment and totalPaymentAmount Web Service methods and displays the results (ch21-1.aspx.vb). Listing 21.6: The MortgageCalculator form's runWebMethods method (MortgageCalculator.frmMortgageCalculator.vb) Listing 21.7: SOAP request message for the Mortgage Calculator Web Service's getPayment method Listing 21.8: SOAP response message for the Mortgage Calculator Web Service's getPayment method Chapter 22: Web Services, COM Components, and the SOAP Toolkit Listing 22.1: Main subroutine for the VB6 Mortgage Calculator client application (modMain.bas) Listing 22.2: Code in frmMain to call and display the Mortgage Calculator Web Service (frmMain.frm) Listing 22.3: The VB6 MortgageCalculateWS project's ch22_payment class contains the Mortgage Calculator getPayment and totalPaymentAmount methods (ch22_Payment.cls). Listing 22.4: The ch22-payment.asmx Web Service is just a wrapper for a VB6- generated COM DLL (ch22-payment.asmx.vb). Chapter 23: Build Your Own Web Controls Listing 23.1: HTML for the prettyXML.ascx file (prettyXML.ascx) Listing 23.2: HTML code for the ch23-1.aspx Web Form that displays the prettyXML User Control (ch23-1.aspx) Listing 23.3: The LabeledTextBox Composite Control code (VBNetCustomControls.LabeledTextBox.vb) Listing 23.4: Default Custom Control class code (DataTable.vb) Listing 23.5: Code for the DateTable Custom Control (VBNetCustomControls.DateTable.vb) Listing 23.6: Code for the ArrayJoin helper class (VBNetCustomControls.ArrayJoin.vb) List of Sidebars Chapter 2: HTML Basics The Hexadecimal System and RGB Color Values Chapter 13: Introduction to ADO.NET DataGrid Formatting

Các file đính kèm theo tài liệu này:

  • pdfMastering ASP.NET with VB.NET.pdf
Tài liệu liên quan