SlideShare a Scribd company logo
ASP NET Professional Projects 1st Edition Hersh
Bhasin download
https://ebookultra.com/download/asp-net-professional-
projects-1st-edition-hersh-bhasin/
Explore and download more ebooks or textbooks
at ebookultra.com
We believe these products will be a great fit for you. Click
the link to download now, or visit ebookultra.com
to discover even more!
Professional ASP NET Design Patterns Scott Millett
https://ebookultra.com/download/professional-asp-net-design-patterns-
scott-millett/
Professional ASP NET MVC 4 1st Edition Jon Galloway
https://ebookultra.com/download/professional-asp-net-mvc-4-1st-
edition-jon-galloway/
Professional ASP NET MVC 3 1st Edition Jon Galloway
https://ebookultra.com/download/professional-asp-net-mvc-3-1st-
edition-jon-galloway/
Professional ASP NET 2 0 XML Thiru Thangarathinam
https://ebookultra.com/download/professional-asp-net-2-0-xml-thiru-
thangarathinam/
Professional IIS 7 and ASP NET Integrated Programming Dr.
Shahram Khosravi
https://ebookultra.com/download/professional-iis-7-and-asp-net-
integrated-programming-dr-shahram-khosravi/
Pro Telerik ASP NET and Silverlight Controls Master
Telerik Controls for Advanced ASP NET and Silverlight
Projects 1st Edition José Rolando Guay Paz (Auth.)
https://ebookultra.com/download/pro-telerik-asp-net-and-silverlight-
controls-master-telerik-controls-for-advanced-asp-net-and-silverlight-
projects-1st-edition-jose-rolando-guay-paz-auth/
ASP NET AJAX programmer s reference with ASP NET 2 0 or
ASP NET 3 5 Dr. Shahram Khosravi
https://ebookultra.com/download/asp-net-ajax-programmer-s-reference-
with-asp-net-2-0-or-asp-net-3-5-dr-shahram-khosravi/
Professional ASP NET 3 5 in C Sharp and Visual Basic Bill
Evjen
https://ebookultra.com/download/professional-asp-net-3-5-in-c-sharp-
and-visual-basic-bill-evjen/
ASP NET Bible 1st Edition Mridula Parihar
https://ebookultra.com/download/asp-net-bible-1st-edition-mridula-
parihar/
ASP NET Professional Projects 1st Edition Hersh Bhasin
ASP NET Professional Projects 1st Edition Hersh Bhasin
Digital Instant Download
Author(s): Hersh Bhasin
ISBN(s): 9781931841214, 1931841217
Edition: 1
File Details: PDF, 4.42 MB
Year: 2002
Language: english
Microsoft ASP.NET Professional Projects
by Hersh Bhasin ISBN: 1931841217
Premier Press © 2002 (638 pages)
Teaches Web developers how to build powerful applications using the .NET
Framework and Microsoft’s ASP.NET.
Table of Contents
Microsoft ASP.NET Professional Projects
Part I - The ASP.NET Programming Environment
Chapter 1 - Introducing ASP.NET
Chapter 2 - Introducing ASP.NET Web Forms and Controls
Chapter 3 - Using ADO.NET in the .NET Framework
Chapter 4 - Data Binding
Chapter 5 - Input Validation
Chapter 6 - User Controls
Chapter 7 - Custom Controls
Chapter 8 - Business Objects
Chapter 9 - Working with ASP.NET Web Services
Chapter 10 - ASP.NET Applications
Chapter 11 - Caching
Chapter 12 - Tracing
Chapter 13 - Security
Part II - Projects
Project 1 - A Personal Finance Manager
Chapter 14 - The Design of the Personal Finance Manager
Chapter 15 - Chart of Accounts
Chapter 16 - Transactions
Chapter 17 - The Trial Balance Report
Project 2 - Web Services
Chapter 18 - Creating a Generic Database Web Service
Chapter 19 - Designing a Navigation System
Chapter 20 - Incorporating Web Services in the Chart of Accounts Form
Chapter 21 - Incorporating Web Services in the Transactions Form
Chapter 22 - Incorporating Web Services in the Trial Balance
Project 3 - Inventory Management System
Chapter 23 - The Design of the Inventory Management System
Chapter 24 - Inventory Masters
Chapter 25 - Inventory Movements
Chapter 26 - The Inventory Balances Report
Project 4 - The GenEditAdd Control
Chapter 27 - Using the GenEditAdd Control
Chapter 28 - Extending the GenEditAdd Control
Project 5 - Visual Studio.NET
Chapter 29 - Displaying Database Data Using a Strongly-Typed DataSet
Chapter 30 - Writing CRUD Applications with Visual Studio.NET
Chapter 31 - Creating a Web Service Using Visual Studio.NET
Part III - Appendixes
Appendix A - Installing the Sample Database
Appendix B - HailStorm
Index
List of Figures
List of Tables
List of Examples
Microsoft ASP.NET Professional Projects
Hersh Bhasin
© 2002 by Premier Press, Inc. All rights reserved. No part of this book may be
reproduced or transmitted in any form or by any means, electronic or mechanical,
including photocopying, recording, or by any information storage or retrieval system
without written permission from Premier Press, except for the inclusion of brief
quotations in a review.
The Premier Press logo, top edge printing, related trade dress and Professional Projects
are trademarks of Premier Press, Inc. and may not be used without written permission.
All other trademarks are the property of their respective owners.
Important: Premier Press cannot provide software support. Please contact the
appropriate software manufacturer's technical support line or Web site for assistance.
Premier Press and the author have attempted throughout this book to distinguish
proprietary trademarks from descriptive terms by following the capitalization style used
by the manufacturer.
Information contained in this book has been obtained by Premier Press from sources
believed to be reliable. However, because of the possibility of human or mechanical error
by our sources, Premier Press, or others, the Publisher does not guarantee the
accuracy, adequacy, or completeness of any information and is not responsible for any
errors or omissions or the results obtained from use of such information. Readers should
be particularly aware of the fact that the Internet is an ever-changing entity. Some facts
may have changed since this book went to press.
ISBN: 1-931841-21-7
Library of Congress Catalog Card Number: 2001096478
Printed in the United States of America
02 03 04 05 06 RI 10 9 8 7 6 5 4 3 2 1
Publisher Stacy L. Hiquet
Associate Marketing Manager Heather Buzzingham
Managing Editor Sandy Doell
Acquisitions Editor Kevin Harreld
Editorial Assistant Margaret Bauer
Technical Reviewer Mingyong Yang
Copy Editor Jenny Davidson
Interior Layout Marian Hartsough Associates
Cover Design Phil Velikan
Indexer Kelly Talbot
Proofreader Kim Cofer
Dedication
To my parents, my wife Ritu, and my daughter Ria
Acknowledgments
I thank my wife Ritu for motivating me to write this book and for painstakingly
proofreading, editing, and formatting all my manuscripts. I thank all my friends at Premier
Publishing who made this book possible. Thank you Kevin Harreld and Jody Kennen for
putting your trust in me, Elizabeth Agostinelli, Jenny Davidson and Brian Thompson for
wading through my work and fixing what was wrong and Mingyong Yang for reviewing
my source code and giving valuable suggestions.
About the Author
Hersh Bhasin has been consulting on Microsoft technologies for some nine odd years
and maintains a Web site on emerging technologies like .NET, SOAP, XML at
http://hersh.weblogs.com. He qualified as a Management Accountant from The
Chartered Institute of Management Accountants - UK (CIMA) and also obtained a
Bachelor of Science degree from the University of Punjab, India. He can be contacted at
hersh_b@yahoo.com
Part I: The ASP.NET Programming Environment
Chapter List
Chapter 1: Introducing ASP.NET
Chapter 2: Introducing ASP.NET Web Forms and Controls
Chapter 3: Using ADO.NET in the .NET Framework
Chapter 4: Data Binding
Chapter 5: Input Validation
Chapter 6: User Controls
Chapter 7: Custom Controls
Chapter 8: Business Objects
Chapter 9: Working with ASP.NET Web Services
Chapter 10: ASP.NET Applications
Chapter 11: Caching
Chapter 12: Tracing
Chapter 13: Security
Chapter 1: Introducing ASP.NET
Overview
ASP.NET is a radical evolution of ASP and its associated data access service, ADO,
which is now called ADO.NET. ASP suffered from many limitations—it was unstructured,
so the code intermingled with the presentation logic, which made applications difficult to
understand and maintain. Due to this limitation of ASP, code segregation was not
possible. You could not hand over the presentation logic to a Web designer and the code
to a developer and ask both to work simultaneously on the application. Unlike windows-
based application development, ASP did not have an inherent component or
programming model. ASP developers had to use a combination of markup languages,
scripting environments, and server platforms to get their work done. Tool support was
limited and although Visual InterDev introduced a Visual Basic type interface that
allowed you to drag and drop components such as text boxes and labels onto a form, it
was clunky and added tons of code to the form, which needless to say scared away most
developers from ever using this product.
ADO, the Data Access component of ASP, had been designed with a view to serving the
data access needs of client/server-based applications. Programming for the Web,
however, followed different rules. A client/server application had no need to optimize
database connections and a typical database operation would open a database
connection and leave it open until the looping operation of an ADO recordset was
complete. Database connections in a Web-based environment, however, were
expensive. Web programming required a disconnected way of manipulating data. Thus
the Remote Data Services (RDS) were born. With the advent of XML (eXtensible Markup
Language), the request/response paradigm became the order of the day. To keep up
with this message-based system of communication, HTTP support was added to RDS,
which allowed business logic to be called at the middle tier. XML follows a
heterogeneous and hierarchical data model (XMLDOM) whereas MDAC (Microsoft Data
Access Technologies) follows a relational model. To work with XML data we had to make
a choice between MSXML and MDAC. But ADO.NET solves this dilemma. XML support
is built at a very basic level and it is quite similar to working with "database" data. No
longer is choosing between MDAC and MSXML an issue.
Web forms, which will be discussed in Chapter 2, "Introducing ASP.NET Web Forms and
Controls," are the fundamental building blocks of ASP.NET. The concept of "Code
Behind" has been introduced, which is the process of writing pres entation logic and
script in separate files. Code Behind seeks to eliminate the clutter and "spaghetti" code
(spaghetti code is code where the scripting portion intermingles with the presentation
logic) that traditional ASP seemed to encourage. ASP.NET provides a server-based,
event-driven programming model similar to Visual Basic, which enables WYSIWYG tools
like Visual Studio to be used.
ASP.NET introduces two sets of controls, the HTML controls and the Web controls,
which are collectively known as "server controls." These controls render HTML for Web
browsers in addition to providing means of preserving state across round trips, detecting
the browser types (and rendering HTML accordingly), and serving as the building blocks
for composite controls. These controls reside on the server and output plain HTML to the
browser. Since all browsers can understand HTML, they are able to overcome the
classic cross-browser compatibility problem.
The HTML controls (textbox, form, button, and so on) are the normal HTML controls that
we have been using so far, with a new runat="server" attribute added. The sole use
of these controls is to provide a quick migration path to ASP.NET as any HTML control
can be converted to an ASP.NET control by adding the runat="server" attribute. The
Web controls, however, provide a high degree of abstraction and usefulness. Four types
of Web controls exist: Intrinsic controls, Rich controls, List Bound controls, and Validation
controls. Intrinsic controls are the ASP.NET versions of traditional HTML controls, such
as textboxes, buttons, and DropDownList. These controls have a special prefix of
ASP.NET that distinguishes them from the normal HTML controls and they also have a
runat ="server" attribute. Thus a textbox is created as follows:
<asp:TextBox id="Text1" runat="server"/>
The purpose of Web controls is to simplify the nomenclature of a control. Controls that
overlapped in their functionality have been reduced to a single control. Properties like
ForeColor, Font, BackColor, Enabled, and so on are consistent among controls.
The developer thus needs to remember one property setting that he can apply to all
controls.
Rich controls consist of the Calendar and AdRotator. The Calendar outputs HTML for
downlevel browsers (these are browsers that do not support DHTML) or DHTML for
uplevel browsers. The AdRotator displays rotating advertisements.
List bound controls are the subject matter of Chapter 4, "Data Binding." There are three
controls in this category: the DataGrid, the DataList and the DataRepeater. These
controls automate the task of displaying database data as lists and data grids. The
developer applies a number of templates to these controls to achieve a high degree of
customization. The DataGrid can even be used for in-place editing of data.
Validation controls, which are discussed in Chapter 5, "Input Validation," automate the
mundane activity of writing validation code. There are five validation controls and one
validation summary control. The validation controls are the
RequiredFieldValidator, RegularExpressionValidator,
CompareValidator, RangeValidator, CustomValidator, and the
ValidationSummary. The work of each of these controls is evident from its name. For
example, the RequiredFieldValidator does not allow the user to leave the required
field blank. Similarly, the RangeValidator verifies whether user input falls within a
specified range. It is a simple task to incorporate validation in an ASP.NET web form. All
you need to do is associate an input text box with the appropriate validation control.
ADO.NET, the latest avatar of ADO, is discussed in Chapter 3, "Using ADO.NET in the
.NET Framework." ADO has seen a massive overhaul (a complete rewrite would be a
better choice of words) in ADO.NET. The foundation of ADO—the recordset—has been
given the golden handshake. As noted above, the recordset understood only the
relational way of doing things, which was appropriate for handling database data. With
the advent of XML, which followed a heterogeneous and hierarchical data model, the
recordset had a hard time keeping up. A new object called the DataSet has been
introduced in ASP.NET. The DataSet is an in-memory copy of the database, complete
with tables, columns, relationships, constraints, and data. It allows relationships to exist
between multiple tables, analogous to a foreign-key relationship in a database. You can
navigate between tables based upon their relationships. The DataSet has some
outstanding qualities. For example, it can talk to a variety of datasources; it can receive
data from a database, an XML file, code, or user input. No matter what the source of the
data within the DataSet is, it is manipulated through the same set of standard APIs. The
DataSet is transmitted as an XML stream and can thus be passed between any objects
(not just COM objects) without interference from firewalls. To transmit an ADO
disconnected recordset from one component to another, COM marshalling had to be
used.
User controls, which are discussed in Chapter 6, "User Controls," are the evolution of the
server-side include files. Include files are static files. User controls, on the
other hand, provide object model support, which enables you to program against
properties and use methods. User controls work much like the ASP intrinsic controls in
that they can expose properties and methods. In Chapter 6, I design a user control that
automates building of the navigation links for a Web site based on the URLs specified in
an XML file.
ASP.NET has a very clean and elegant approach to authoring custom controls. In
Chapter 7, "Custom Controls," I discuss the process of authoring custom controls in
detail. I also show you how to build a component (which I call "GenEditAdd") that you
can use to extend the DataGrid's functionality. The DataGrid does not have the
functionality to insert records. Using the GenEditAdd component, you can automate the
process of record insertion. You can also use the GenEditAdd component in lieu of the
editing functionality provided by the DataGrid, which requires you to code a number of
events. The GenEditAdd component requires simple property settings and the code
generation is automatic.
Encapsulating business logic into components has always been an important part of both
Web and client/server applications. ASP.NET has greatly simplified the process of
registering components. If you have developed COM objects in the past, you must know
the pain involved in registering components. A component had to be registered using the
regsvr32 utility. If the component was modified, the entire Web server had to be stopped
in order to re-register the component. This was called "DLL Hell." In ASP.NET,
components are simply copied and pasted in the bin directory and no registry updates
are required. Chapter 8, "Business Objects," looks at this important topic.
Web service is the main protagonist of the .NET arena and the content of this book and
its projects reflect its importance. A web service is a combination of three things: a
function written in a .NET-compliant language, SOAP, and XML. When you need to
reuse logic in a number of places, the best way to do so is to write the code as a
function. A collection of functions that share some common goal can be combined into a
business object. For example, the four basic database operations are insert, delete,
update, and select. We can write a generic function for each operation and pack them
together in a business object called (say) DataBaseClass. Now this class, together
with its functions, can be initiated and called in any object that needs to use its
functionality. A web service is a Web-enabled business object, which is a collection of
functions that can be called over the Web. Functions written for a web service are written
as normal functions, and the only difference is that the functions are preceded with a
special tag that marks them as web services. A standard called SOAP (Simple Object
Access Protocol) sets out the rules that must be followed by the machine that makes a
function call and the machine that responds to that call by sending a resultset back. The
request and response is made in XML and the XML document follows the rules set out in
the SOAP standard. Exchanging information as XML enables a client application to call a
function on the server, regardless of what operating system each is running, what
programming language each is written in, or what component model is supported on
each. This is because XML is basically a text file that all machines can understand and
because SOAP uses HTTP, which is the most common Internet transfer protocol and
one that is used by essentially all Web browsers. Chapter 9 "Working with ASP.NET
Web Services," provides a detailed discussion on web services.
Chapter 10, "ASP.NET Applications," covers ASP.NET applications. An ASP.NET
application is an IIS virtual directory and its subdirectories. All of your Web application
files go into this folder. This folder has a special subdirectory called bin. All the compiled
business objects and web services reside here. When you want to register a new
component, you just copy and paste the DLL file in this folder (as opposed to using
regsvr32). This folder also contains two special files: web.config and global.asax. The
web.config file is an XML file that you use to configure various facets of the application.
For example, you can use it to set up and configure security, caching, or tracing. The
global.asax file contains application-level program directives, handlers for application
and session-level events, and declarations of objects that are globally accessible to all
parts of the application. In general, this file enhances the functionality that was provided
by the global.asa file in ASP.
Chapter 11, "Caching," deals with caching, which is the process of keeping frequently
visited Web pages in memory. The theory behind caching is that there are some items of
the Web site that are very expensive to construct and that such items should be created
once and then stashed away in memory for a fixed duration of time or until they change.
Subsequent calls to these resources will not re-create the resource but simply retrieve it
from the cache. Such items are typically resources that remain unchanged over a period
of time; for example, shopping lists or price lists.
Chapter 12, "Tracing," discusses tracing. Developers have often resorted to writing a
number of Response.Write() statements in the code to try to debug errant code.
When the problem is located, these debugging statements must be cleared out. This
method is cumbersome and error-prone, because you might accidentally remove code
along with the debugging statements. ASP.NET introduces an elgant way of writing such
debugging code. Debugging is enabled by adding a page-level directive (or by enabling it
in the web.config file). Debugging statements are then written using Trace.write()
instead of Response.Write(). When the form has been debugged, there is no need to
remove these statements from the body of the form. You can simply disable Trace and
these statements will not be displayed in the browser.
Security is discussed in Chapter 13. ASP.NET implements authentication through
authentication providers. These authentication providers are modules that contain code
required to authenticate the credentials of the requesting user. Three authentication
providers are currently available: Windows Authentication, Passport Authentication, and
Cookie Authentication. All three providers are discussed.
In Project 1 (Chapters 14 to 17), I show you how to build a Web-enabled personal
finance manager using ASP.NET web forms. This project is spread over four chapters. In
this project, I take a product that has its roots in the client/server era—a personal finance
accounting module—and revamp it for the Web. A personal finance manager is an
accounting application, such as Quicken or Microsoft Money that enables you to
maintain bank, cash, credit cards, and investment accounts. This project is designed to
be a production quality accounting application and makes use of stored procedures and
database triggers. It's comprised of web forms to maintain your chart of accounts,
transactions details and it even draws up a trial balance report.
The Internet brings some exciting possibilities to the traditional way of designing
applications. The various modules of an accounting application need no longer be
connected with "wire." Using ASP.NET and web services, we can design applications
that can send and receive data using the Internet and HTTP. In Project 2 (which spreads
over five chapters), I build generic database access services that can then be used to
interact with any database. This service has functionality to insert, update, delete, and
select records from a database. This web service accepts a database connection and a
valid SQL query as parameters. If the query is an action query (insert, update, or delete),
the appropriate action is performed. If the query is a select query (which returns a
resultset), a DataSet is returned to the calling object. This DataSet can then be used to
bind a control like a DataGrid. I demonstrate this service by incorporating it in the
personal finance manager that was developed in Project 1. This project also
demonstrates use of the navigation user control that was built in Chapter 6, "User
Controls." This navigation control builds the site navigation of the application using URLs
defined in an XML file.
The advantage of having a navigation system separate from the main application is that
you can add or delete links (by modifying the XML file) without having to change the Web
pages in the application.
In Project 3 (Chapters 23 to 26), I have taken another application that has traditionally
been a client/server application and revamped it for the Web. This is an inventory
management application. This application makes use of the database web service class
that was developed in Project 2. It also makes use of various stored procedures and
triggers.
In Project 4 (Chapters 27 and 28), I enhance the functionality of the custom control
GenEditAdd (which was initially developed in Chapter 7). The GenEditAdd control can be
used to insert or update database records. The DataGrid does not have the capability to
insert records, although it does have editing capabilities. The edit mode of the DataGrid
is quite cumbersome, as you have to code a number of events in the DataGrid for the
process to work. This control was developed to enhance the usefulness of the DataGrid.
It can be hooked up to a DataGrid to provide both editing and insertion capabilities in a
consistent manner. This control works by setting various properties and the code
generation is automated.
In Project 5 (Chapters 29 to 31), I discuss the important features of Visual Studio. In
Chapter 29, "Displaying Database Data Using a Strongly-Typed DataSet," I begin with
an overview of the important features of Visual Studio.NET, focusing on the various
wizards, tools and components available. I'll also show you how to use the typed
DataSet to display database information using the Visual Studio.NET drag and drop
features. In Chapter 30, "Writing CRUD Applications with Visual Studio.NET," I'll show
you how to interact with the database using Visual Studio.NET. I'll show you how to add,
delete, and update database rows. I'll also show you how to customize a DataGrid by
enabling paging and sorting from within the Visual Studio.NET. Finally, in Chapter 31,
"Creating a Web Service Using Visual Studio.NET," I'll show you how to develop and
consume web services with Visual Studio.NET.
Installing the .NET Framework SDK
The .NET SDK can be downloaded from the Microsoft download site at
http://msdn.microsoft.com/net/. It is quite a large download and you might want to
consider ordering a CD, which will ship at a nominal charge.
There are two versions available; a standard version or a premium version. The premium
version includes additional features like output caching, web farm session state, code
access hosting and support for four and above CPUs.
Installation is straightforward and involves running the setup.exe. If prompted, you
should update the Windows Installer Components. You should also apply the latest
patches for your Windows version. You should also update your version of MDAC
(Microsoft Data Access Components) to the latest version, which is currently version 2.7.
If the installer complains that ADO 2.7 is not installed, you can still proceed with the
installation by disregarding the complaint. You will be given a choice to install the SDK
samples. The samples are a rich source of information and you should choose to install
them. A named instance of the Microsoft Data Engine (MSDE) is installed along with the
samples and this contains the sample database.
Tip A limited-time evaluation copy of Microsoft SQL Server can be
obtained from
http://www.microsoft.com/sql/evaluation/trial/2000/default.asp. You
can also order this copy on a CD and only pay the cost of shipping.
After you have SQL Server up and running, install the ASP.NET QuickStart samples.
These samples are an excellent training resource on ASP.NET. To install these samples,
open the Microsoft NET Framework SDK/Samples and QuickStart
Tutorials link, which is added to your programs during the SDK installation and follow
the installation steps. Once the samples are installed, they can be accessed at
http://localhost/quickstart/default.aspx.
After you install the SDK, all you need is a text editor to write your scripts. You can also
order the Visual Studio CD set (again at a nominal charge) and use it to develop your
scripts. If you have the Visual Studio CDs, the Framework SDK is on the second CD.
I have discussed development with Visual Studio, where appropriate, and one entire
project (Project 5) is dedicated to exploring this development tool. I have left discussion
of Visual Studio till the end because I want my readers to be familiar with the internals of
ASP.NET before using the wizard-like tools of the Visual Studio IDE, which hides the
intricacies of code development. A text editor that
I highly recommend is TextPad, which is shareware and available at
http://www.textpad.com. You can also download the syntax definition file for .NET from
its site. This file will display various ASP.NET keywords in different colors.
Chapter 2: Introducing ASP.NET Web Forms and
Controls
ASP.NET forms are designed to overcome a number of shortcomings inherent in ASP
pages. In these pages the HTML elements and script code are necessarily intertwined
making the resultant page very cluttered. These pages are not easily edited with
WYSIWYG tools. ASP.NET improves on the ASP page and adds many interesting
enhancements to it. It provides a server-based, event-based programming model similar
to Visual Basic. It introduces a technique called "Code Behind," which allows the
developer to keep the script code in a file separate from the HTML markup. ASP.NET
introduces two sets of controls, the HTML controls and the Web Controls, which are
collectively known as "server controls." These controls render HTML for Web browsers in
addition to providing means of preserving state across round trips, detecting the browser
types (and rendering HTML accordingly), and serving as the building blocks for
composite controls. A round trip occurs whenever the user submits a form or an event
occurs that causes a post to the server; for example, the user fills out a text box on a
form and clicks on the submit button. The server processes the information passed onto
it and sends the page back to the client for display. The original state of the form is
maintained by ASP.NET. This means that when the user fills out a text box and submits
the form to the server, the text box will retain this information even after the round trip.
This is a welcome change from traditional ASP programming where the developer had to
take care of maintaining state, as the user-input values were lost after every post.
Basic Techniques
To create an ASP.NET form you simply save a text or HTML file with the .aspx
extension. No special tools are needed and you can use an editor like Notepad for the
job. You can also use Visual Studio.NET, a rapid application development environment
(RAD) that allows you to drag and drop controls onto a form.
ASP.NET forms also provide selective backward compatibility. For example, you can use
normal ASP code and mix script tags with HTML elements using the <% %> blocks. ASP
and ASP.NET applications can run side by side on the IIS without interference. However
ASP applications developed using the Visual Basic Scripting Edition will need to be
modified to port to ASP.NET.
In ASP.NET, script blocks are compiled and not interpreted, leading to enhanced
performance. Compiling the code involves converting the code instructions to the
machine language. In ASP.NET however, code is not compiled to machine language
directly. It is instead compiled to an intermediate language called Microsoft Intermediate
Language (MSIL or IL). IL code is further compiled to machine language using the JIT
compiler (just-in-time compiler). The JIT compiler compiles each portion of code as it is
called, instead of compiling the complete application in one go. This leads to faster start -
up time. The resultant compiled code is stored till the application exits and hence does
not have to be recompiled each time that portion of code gets called. Using this process,
it is expected that execution of IL code will be almost as fast as executing native
machine code.
State Management
Though you can use the script blocks, they do not lead themselves to a clean
programming environment. Consider the basic requirement of maintaining state in a
"post back" form. This is a form that accepts user input and "posts back" to itself. It
needs to remember the values entered so that, if the user makes a mistake, it can
display the values the user had earlier entered so that he can correct them.
Coding for such a form in the ASP environment has involved using the Response object
to extract the value and a <% =some variable %> block to display the passed value.
Here is an example:
State.asp
<html>
<form method="post">
<br>
<h3> Name: <input name="Name" type=text value="<%=Request.form("Name")%>">
<br> <input type = "submit" value = "Submit">
</form>
</html>
In ASP.NET, state management is enabled automatically when you use server controls
within a form control as follows:
State.aspx
<html>
<body style="background-color='beige'; font-family='verdana'; font-size='10pt'">
<form method="post" runat=server>
<h3> Name: <asp:textbox id="Name" runat="server"/>
<asp:button text="Lookup" runat="server"/>
</form>
</body></html>
Note that the form automatically "remembers" input values. There are a few drawbacks
associated with using server controls for state management. You can only use the
"post" method and can only have a single form on your page.
Page Events
ASP.NET has object orientation at its heart. You can code various events in a Visual
Basic–like manner. As the form loads, the Page_Load event is fired, form controls
become available for use and, as the user continues to interact with the form, other
events are generated. The form unload event occurs when the page is unloaded. Due to
this event-based structure, a developer can finally start applying event-based coding
techniques to Web applications. Figure 2.1 shows you how to accept user-input values to
perform a calculation using these techniques.
Figure 2.1: Page Events.
Events.aspx
<%@ Page Language="vb" %>
<html>
<head>
<script Runat="server">
Sub Calculate(src As Object, e As EventArgs)
Amount.Text = Cstr(cint(qty.text)*cint(price.text))
End sub
</script>
</head>
<body style="background-color='beige'; font-family='verdana'; font-size='10pt'">
<h4> Page Events </h4>
<form method="POST" runat="server">
Qty:<asp:TextBox id="Qty" Runat="server"/>
Price: <asp:TextBox id="Price" Runat="server"/>
Amount:<asp:TextBox id="Amount" ReadOnly = "true" Runat="server"/>
<asp:Button id="btnCalculate" Text="Calculate" OnClick="Calculate"
Runat="server"/><br>
</form>
</body>
</html>
At the top of the page, I specify that we are going to be using Visual Basic as the
scripting language with the @ Page Language declaration. Each object can be assigned
an id property. This enables me to extract property values for the object using its id
property. In this example, I am accessing the text property for the Price and Qty
textboxes instead of accessing the posted data using the response object. I put my code
in the OnClick event of the button, thus making use of the new event-based paradigm
of ASP.NET. Finally, note how I am able to set the ReadOnly property of the Amount
textbox simply by setting its property value to "true".
Code Behind
As mentioned earlier, a major limitation of ASP is the way the script code intermingles
with the HTML tags. This makes the separation of content from presentation difficult. The
page becomes difficult to maintain and, in shops where developers and designers work
together, segregation of tasks becomes impossible.
Code Behind is a technique to separate the content from the script. A form can become
really cluttered with script code and html tags. To reduce this clutter you can lift out all
the script code from a web form and put it in a separate file. If you are using Visual Basic
code, this file will have an extension of .vb and if you are using C#, .cs.
The first thing you do in a Code Behind file is to import namespaces. This is the first
construct in the Code Behind file. Namespaces can be thought of as including references
in a Visual Basic project. When you make a reference to a DLL in Visual Basic, you can
access the methods contained in that DLL. Similarly, by importing a namespace, you can
access all the functionality residing within that namespace in your web form. If you do not
use this declaration, you have to provide a fully qualified path when referring to a method
residing in a particular namespace. This fully qualified path name can become very long
(and a pain to type). Using the import directive allows you to directly refer to the method
by name. Here are some of the commonly used Namespaces:
§ The System namespace contains fundamental classes and base classes that
define commonly-used value and reference data types, events and event
handlers, interfaces, attributes, and processing exceptions.
§ The System.Collection namespace contains classes that define lists,
queues, arrays, hashtables and dictionaries.
§ The System.Web.UI.Control is the parent of all Web Form Controls. Three
commonly used controls belong to this namespace—Page, UserControl and
LiteralControl. Every ASP.NET page is compiled to the Page control by the
ASP.NET page framework.
§ The System.Web.UI.WebControl namespace contains classes that define
the ASP.NET server controls.
§ The System.Web.UI.HTMLControlsnamespace contains classes that define
HTML controls.
§ Namespaces like System.Data, System.Data.OleDb, System.Data.
SqlClient, System.XML are classes that deal with manipulating database, XML
and other data. I will look at these namespaces in Chapter 3.
I will be discussing these namespaces at various places in the book. In this chapter, I will
be discussing the System.Web.UI.WebControl namespace and the
System.Web.UI.HTMLControls namespace.
Note "Imports" is a Visual Basic construct. If you are using C#, you
will substitute "Using" for "Imports".
If you have included Web Controls in your .aspx form and want to refer to them in your
Code Behind file your import construct will look like the following:
Imports System
Imports System.Collections
Imports System.Web.UI
Imports System.Web.UI.WebControls
You then define a class. All your functions and subs go in this class. A Visual Basic Code
Behind file might look like this:
Imports System.Data
Public Class BaseClass
Inherits System.Web.UI.Page
Sub somesub()
End Sub
Function somefunction()
End Function
End Class
Note that I have introduced the Inherits keyword here. The difference between the
Inherits and Imports keyword is that the Imports statement only brings in the
definition of a set of functionality, but does not actually make use of it. It is comparable to
including a reference in Visual Basic. The Inherits keyword is more dynamic. An
object that inherits certain functionality can also override and/or extend the parent
functionality.
This form becomes a base class and one that your aspx page will inherit from.
Inheritance is quite simple. You just have to put a statement at the top of the aspx form:
<%@Page Language="VB" Inherits="BaseClass" Src="nameofCodeBehind.vb" %>
Let's take a look at an example. We will take the Events.aspx file and split it into two
files: events_cb.aspx and events_cb.vb, the Code Behind file.
events_cb.aspx
<%@Page Language="VB" Inherits="BaseClass" Src="events_cb.vb" %>
<html>
<body style="background-color='beige'; font-family='verdana'; font -size='10pt'">
<form method="POST" runat="server">
Qty:<asp:TextBox id="Qty" Runat="server"/>
Price: <asp:TextBox id="Price" Runat="server"/>
Amount:<asp:TextBox id="Amount" ReadOnly = "true" Runat="server"/>
<asp:Button id="btnCalculate" Text="Calculate" OnClick="Calculate"
Runat="server"/><br>
</form>
</body>
</html>
Events_cb.vb
Imports System
Imports System.Collections
Imports System.Web.UI
Imports System.Web.UI.WebControls
Public Class BaseClass
Inherits System.Web.UI.Page
'Each control used on events.aspx to be declared here with same id
Protected qty as textbox
Protected price as textbox
Protected amount as textbox
Sub Page_Load(Source As Object, E As EventArgs)
'this is the page load event
'gets fired each time the page is loaded
response.write("Page Load Event : -->fired <br>")
if NOT (isPostBack)
'the code here gets fired only one at page load
'subsequent reloads do not fire it due to the not isPostBack construct
response.write("The not isPostBack construct:--> ensures this does not get fired at
reloads")
end if
End Sub
'This sub moved from the events.aspx form
Sub Calculate(src As Object,e As EventArgs)
Amount.Text = Cstr(cint(qty.text)*cint(price.text))
End Sub
End Class
Let's discuss the example in detail:
1. I have defined a class called BaseClass in the Code Behind file and moved
the Calculate sub from the aspx form into this class. This class inherits
from the System.Web.UI.Page.
2. I will be extracting the text value of textboxes Qty and Price, multi- plying
the two, and putting the result in the Amount textbox. Since I need to access
the property values of these three textboxes from my Code Behind file, I
declare three textboxes with the same id in the Code Behind file like this:
3. Protected qty as textbox
4. Protected price as textbox
Protected amount as textbox
5. The Qty, Price, and Amount textboxes are WebControls since I have
initialized them with the asp: tag prefix. For example, the Qty textbox is
created as follows:
<asp:TextBox id="Qty" Runat="server"/>
Controls exist in the System.Web.UI.WebControls namespace hence I must
import this namespace before I can access their properties by code. This is
done by the import directive at the top of the page:
Imports System.Web.UI.WebControls
6. Finally, I have coded the Page_Load Event to display a message when it gets
fired. This event gets fired each time the page gets loaded.
At times we need to code events that get fired only at the initial page load and
not on subsequent reloads. For example, we can bind a Web Control to a
data source (I will be discussing data binding in Chapter 4) and want the
binding to occur only once at page load.
The isPostBack property of the page lets us determine if posting has
already occurred to the page. Thus we use the following construct to display a
message only on the first load of the page:
IF NOT (isPostBack)
response.write("The not isPostBack construct:—>……")
End If
Server Controls
There have been many attempts to encapsulate HTML rendering into controls. We have
had objects like VBXs, OLE controls, and ActiveX controls, all of which attempted to give
us a simple way to generate HTML. The problem with these controls is that they made
the presumption that the users accessing our sites would have the very latest browsers.
The server side controls introduced with ASP.NET make no such requirement of the
browser. They render pure HTML to the browser, thus overcoming the shortcoming of its
client side brethren. These server controls are fully encapsulated objects that expose
events, properties, and methods to programmatic access. They exist independent of the
web form on which they are drawn.
ASP.NET provides two sets of controls: HTML and Web Controls. HTML controls
correspond to traditional HTML controls with the same name. Web Controls provide
features such as automatic browser detection, a consistent object model, and data
binding capabilities.
HTML Controls
HTML controls belong to the System.Web.UI.HTMLControls namespace and derive from
the HTMLControl base class. They are initiated with the runat = "server" attribute.
For example, the following HTML creates an instance of a HTMLInputText named
textbox 1.
<Input type = "text" runat="server" id = "textbox1" value ="test">
These controls map directly to their HTML counterparts and are useful for providing
backward compatibility with ASP. These controls do not provide any abstraction like their
Web Control counterpart and do not automatically detect the requesting browser to
modify the HTML they render. The main use of these controls is to provide a quick
migration path to ASP.NET as existing HTML tags can be upgraded to server controls
just by supplying the runat = "server" attribute.
I have provided examples of various HTML controls in the following example with a
detailed discussion of each one afterwards. Figure 2.2 shows various HTML controls.
Figure 2.2: HTML Controls.
htmlControls.aspx
Random documents with unrelated
content Scribd suggests to you:
Merrimeg, looking up, could see the bare spot in the sky directly
overhead, where the lost star belonged.
“Where are you taking us?” said Pennie.
“I’m taking you to the gnomes’ house,” said Merrimeg. “We’ll soon
be there. It’s two gnomes who’ve been very good to me; I know
where they live. They’re the ones to help us.”
“Is one of them named Malkin?” said Florrie.
“And the other one Nibby?” said Pennie.
“Yes,” said Merrimeg.
“LOOK!” SHE CRIED
“Then it’s no use,” said Pennie. “We’ve been there already.”
“They were asleep,” said Florrie, “and we woke them up, and they
didn’t like it a bit. They wouldn’t get up for any foolish old star,—
that’s what they said. But they told us about you, and that’s how we
came to hunt you up. But the horrid gnomes wouldn’t do a thing for
us; they wouldn’t even get up.”
“They’re not horrid,” said Merrimeg. “Oh dear, I don’t know what
we’re going to do now.”
She looked down sadly into the dark water of the pool, trying to
think what to do next. She gave a little jump of surprise, and looked
harder. Far, far down, away down deep under the water of the pool,
——
She saw a star.
“Look!” she cried, and pointed her finger at it.
The starlight fairies leaned over, and looked down into the pool.
“That’s it!” cried Florrie.
“It’s my star!” cried Winnie.
“It’s our lost star!” cried Pennie. “Dropped down from the sky to the
bottom of this pool.”
“Then,” said Merrimeg, “you’d better go down and get it.”
“Oh no! oh no! oh no!” cried the three fairies together.
“We mustn’t get our wings wet!” said Pennie.
“We’d never be able to fly home if our wings got wet,” said Winnie.
“But you have no wings,” said Florrie to Merrimeg.
“No, she has no wings,” said Pennie.
“She shall go down for our star,” said Winnie. “You will, won’t you?”
“The water’s deep and dark,” said Merrimeg.
“But you have no wings,” said Florrie.
“The water’s cold and gloomy,” said Merrimeg.
“But you have no wings,” said Pennie.
“I wonder if I could do it,” said Merrimeg.
“Oh please!” cried Winnie. “Oh dearest Merrimeg, please get my
star.”
“I’ll see how deep it is,” said Merrimeg, and she threw a stone into
the middle of the pool. The water rippled away as the stone sank,
and the star could not be seen any longer.
“Oh!” cried Winnie. “Now you’ve sent my star away! It’s gone!”
But the water became quiet in a moment, and there was the star
again, shining bright at the bottom of the pool.
At that instant, they heard a splash in the water, and a shrill voice,
like the voice of an angry boy, cried out:
“Who breaks my glass? Who breaks my glass?”
“What can that be?” whispered Merrimeg.
“I don’t know,” said Florrie. “Throw another stone, and perhaps we’ll
hear it again.”
Merrimeg tossed another stone into the pool, and when the ripples
had died away they heard the same voice again. This time it said:
“Who strikes my children? Who strikes my children?”
“Throw another,” whispered Pennie, and Merrimeg cast in another
stone.
This time there was a loud wail, and the voice cried:
“My children! My children! I’m coming! I’m coming!”
Then there was a splash, and nothing more. They waited a long
time, but they heard nothing more.
“I’m going to see,” said Merrimeg. “I may have hurt somebody. I can
see better from the end of that log.”
There was a dead log, the trunk of a fallen tree, lying out from the
bank of the pool into the water, and Merrimeg stepped onto it and
getting down on her hands and knees crawled out to the end of it. It
was slippery, and she had to hold on very carefully to keep from
falling off into the water.
She leaned over as far as she could and looked down into the pool.
She looked everywhere for the star, but she couldn’t see it; there
seemed to be some dark thing under the water between herself and
the star.
“The star is gone!” she said to the others, in a whisper.
As she said this, a hand came up out of the water and seized her
wrist and pulled her off the log. Over she went into the pool, down,
down, far down. The hand never once let go of her wrist. It pulled
her down and down, faster and faster. At first she thought she was
going to choke with the water, but in a moment she was all right
again, only wet, very wet. And in another moment she was at the
bottom, and the hand let go of her wrist. She stood up on her two
feet on a floor of what looked like glass.
There was a pale light shining all about her through the water, and
she saw that it came from the star, lying on the floor nearby. Just
over her head was a roof of glass, and it was badly broken in three
or four places. Around her were walls of glass. She was in a little
house of glass, with a broken roof, and full of water.
A hand took hold suddenly of her arm, and she was dragged across
the floor in a great hurry, by the creature who had pulled her down
from the log. It was a sprite; a water sprite, whose head just
reached to her shoulder; full-grown, evidently, in spite of being so
small; with pointed ears, and no hair on his head, and long green
water grass trailing around him.
He dragged Merrimeg straight to the star, and picked it up by a kind
of sling that it was meant to hang by. It flashed and glittered as he
snatched it up.
He pointed to the floor, and Merrimeg saw, lying there side by side,
three tiny sprites, babies, no bigger than kittens, and exactly like the
grown one who was holding her arm. They looked as if they were
asleep, but on the forehead of each one was a black and blue
bruise, and Merrimeg knew that she must have hurt them with her
stones, as well as broken the glass of their little home.
Their father, if it was their father, motioned to her to pick them up.
She gathered them up in her arms, and the sprite, carrying the star
in one hand, seized her hair with the other hand and sprang up
towards the holes in the broken glass roof; and in another instant
she was being dragged upward through the water as fast as she had
been pulled down.
UPWARD THROUGH THE WATER ...
She almost dropped the little mites she was holding in her arms, but
she hugged them tighter, and when they came to the surface of the
pool she was holding them safe in her arms.
They came out dripping on the bank of the pool, and there were the
three starlight fairies.
“Oh!” cried Winnie. “She’s brought my star!”
The water sprite dragged Merrimeg onto the dry grass, and took the
three babies from her arms and laid them down on the grass.
“Now! now! now!” he cried. It was plain that he was very angry. He
was trembling all over. “What are you going to do about it? Look
what you’ve done.”
“Why,” said Merrimeg, “why——”
“First comes this horrible star and breaks in the roof of my house
and lets in all the water! And then—oh you wicked creatures!—you
throw down your ’bom’nable stones and break my roof all to pieces
and kill my children—my poor children—look at ’em—look at ’em, will
you?—look at those bumps on their foreheads—oh my poor children
—You ’bom’nable creatures, you! You perfectly awful wicked
’bom’nable——”
“Oh!” said Florrie. “It’s too bad. I’m so sorry.”
“We didn’t mean to do any harm,” said Pennie.
“And after he was so kind as to bring our star back to us, too,” said
Winnie.
“Is this your star?” cried out the water sprite.
“Yes, yes! It’s mine!” said Winnie.
“Then you’ll never get it! You shan’t have it!” cried the water sprite,
angrier than ever. “You’ll see what I’m going to do with it! You’ll
never get it again! Ah! there she goes!”
He swung the star by the sling in his hand, and gave it a great fling,
and away it flew over the tree tops, in a beautiful bright curve,
higher and higher, and then lower and lower.
But he was greatly mistaken if he thought he could get rid of the
star in any such way as that. Quick as a flash all three of the
starlight fairies were in the air, and off like three arrows over the tree
tops after the star. Before Merrimeg knew what was happening they
were out of sight, and the star was gone.
The water sprite was so astonished that he forgot he was angry.
“Who are they?” he said, in a kind of whisper.
“They’re the starlight fairies,” said Merrimeg. “They hang out the
stars each night, and to-night they dropped that star by accident,
and it fell into your pool. If they don’t get it back they can’t go
home.”
“But they killed my children and——”
At that moment the lost star appeared over the tree tops, coming on
towards them in a streak of white light, and in another moment the
three starlight fairies stood on the ground, and Winnie was swinging
the star in her hand.
“Oh! oh!” she said, and began to laugh and cry at the same time.
She couldn’t say another word, for joy.
“We’ve got it!” cried Florrie. “We can go home now!”
“But what about these poor babies?” said Merrimeg. “Can’t we do
anything for them?”
The three fairies knelt around the three tiny bodies on the ground,
and looked closely at their foreheads.
“Why,” said Pennie, “it’s nothing but a bruise!”
“So it is,” said Winnie and Florrie together.
“Is that all?” said Merrimeg.
“Is that all?” said the water sprite, looking very helpless and pitiful.
“Yaa! yaa!” came a little piping cry from the grass, and the water
sprite dropped to the ground beside the babies.
“He’s crying!” sang out the water sprite. “His eyes are open!”
Another little cry and another came from the grass, and the water
sprite sang out again:
“They’re all crying! They’re all coming to! They’re all right! Hurrah!”
He picked up the three babies and bundled them in his arms, and
without another word gave a leap into the water and splash! went
down and out of sight, babies and all.
Florrie laughed, Winnie laughed, and Pennie and Merrimeg laughed
too.
“But I’m sorry his house is ruined,” said Merrimeg.
“Oh, he’ll mend it in no time,” said Florrie. “But see, Merrimeg,
you’re all wet!”
“Goodness!” said Merrimeg. “I’d forgotten all about it.”
“Stand here,” said Florrie, and she and the other two fairies placed
Merrimeg in the middle and turned their backs to her.
Their wings began to flutter gently, and then began to move faster
and faster, making a strong breeze which blew all over Merrimeg.
Fanned in this way by the great butterfly wings, she was soon dry.
“Good-by, Merrimeg,” said Florrie.
“Good-by, dear Merrimeg,” said each of the others.
“Thank you for my star,” said Winnie. “You must think of us
whenever you look up at the stars.”
“Indeed I will,” said Merrimeg.
The starlight fairies stood on tiptoe for a moment, and fluttered their
wings; and then they rose quietly in the air, and flew straight up.
When they were above the tree tops, they began to circle round and
round, going higher and higher; far, far up through the night they
went on circling; and long after Merrimeg could see them no more,
she could see the star, bright as a diamond, go circling up and up....
She ran away home, and crept in quietly at the front door, and lay
down in her bed and snuggled under the covers. Her mother was
still asleep. She must have gone to sleep herself presently; she woke
up and thought of the lost star, and remembered that she had not
waited to see if it was in its place. She got out of bed and tiptoed to
the window, and putting her head out looked up.
A star was sparkling just overhead, where there had been none
before. The star was in its place.
“I’m glad of that,” she said out loud.
“What did you say?” said her mother, waking up.
“I was only saying—only saying——”
“Never mind what you were saying. Go back to bed, and go to sleep.
You’ll catch your death of cold.”
“Yes, mother,” said Merrimeg.
“N
MERRIMEG AND THE ECHO DWARFS
MERRIMEG AND THE ECHO DWARFS
OW, Merrimeg,” said Merrimeg’s mother, “take this basket and
go to the brook in the woods, and bring me back a basketful
of water cress for supper. And be sure to come straight back.”
“Yes, mother,” said Merrimeg. And she went off down the village
street singing, with her basket on her arm. But first she put in her
pocket the blue saltcellar from the kitchen, full of salt.
She walked a long way into the woods, and at last she came to a
little brook running along over the stones. There in the clear water
she found plenty of fresh green water cress growing. She pulled it
up by the handful and filled her basket with it.
She knew that she ought to go straight home, but this was not one
of her days for being good. She left the basket on the grass, and
took out of her pocket the saltcellar with the salt in it. Then she
looked around for birds.
A blue bird came hopping by on the ground, and Merrimeg stole up
behind it on tiptoe, and sprinkled a little salt right down over its tail.
But just at that minute the bird flew up into a tree, and Merrimeg
was too late.
Off went the bird from tree to tree, and Merrimeg ran after it as fast
as she could, holding out her saltcellar. Pretty soon the bird hopped
down onto the ground again, and Merrimeg tiptoed up behind it and
sprinkled her salt down over its tail. But she was just a bit too late,
and the bird flew up into a tree.
Merrimeg followed the bird a long, long way, and whenever it
hopped down onto the ground she tried to sprinkle a little salt on its
tail; but she was always just a wee bit too late.
At last, when she was at the foot of a hill that rose up out of the
woods, she stamped her foot and cried out:
“Oh, you good-for-nothing naughty bird!”
“Naughty bird!” came back her own voice to her from the top of the
hill.
Merrimeg was astonished. She had never heard an echo before.
She thought she would try it again, so she called out:
“Oh, you naughty bird, come down here!”
Her own voice came back to her from the same place up the hill, but
it didn’t quite repeat her words; it said:
“Come on down!”
The echo must have made a mistake. Merrimeg was more than ever
astonished. She waited a minute, and then the same voice came
down to her from the top of the hill, and it said:
“Down here!”
The echo had got it right this time. Evidently it must have been a
very young echo indeed.
Merrimeg forgot all about the blue bird, and she began to climb the
hill to find out who it was that was mocking her.
She didn’t know it, but there was an Echo Dwarf who lived in a cave
near the top of the hill, and there lived with him his little boy, a very
little boy, who was just learning how to make echoes. Big Hark was
the father’s name. Little Hark was the little boy’s name. Big Hark had
a great deal of trouble in teaching Little Hark to make echoes, for
Little Hark often forgot, and instead of calling back the same words
he had heard, he would often call back words of his own. Besides, if
the words he had to call back were big words, he always got them
mixed up. His father never knew when he was going to make a mess
of everything. And when he did that, it made Big Hark so angry he
could hardly speak.
Merrimeg went on up the hill, and pretty soon she called out again:
“Why couldn’t I catch the bird with my salt?”
“Too slow!” came back the voice from the top of the hill.
Merrimeg couldn’t understand this at all. She listened for a minute,
and then she heard another voice up above her:
“OXTRAGOB BORGS, GOOBLIK!”
“My salt! Oxtragob borgs, gooblik!”
This was Little Hark’s father, and when he said “Oxtragob borgs,
gooblik!” he meant, in the private language of the Echo Dwarfs,
“Wrong again, stupid!”
Big Hark and Little Hark were standing in front of their cave, and Big
Hark was letting Little Hark practice at making echoes, as Merrimeg
came up the hill. Not many people came that way, and Big Hark was
glad of the chance to give his little boy a lesson.
Merrimeg came on further and further up the hill, and after a while
she stopped and called out again:
“Are you still there?”
“Still there!” came back the voice.
This made her quite angry. She did not like to be mocked every time
she opened her mouth. She cried out:
“Stop mocking me!”
“Mocking me!” came back the voice.
This made her very angry indeed. Without saying anything more she
clambered on up the hill and stopped all out of breath on a little
ledge before the mouth of a cave. There a little further on along the
path was standing Little Hark himself, with his hands up to his
mouth, all ready to shout back an echo. His father had gone inside
the cave.
Little Hark was very small indeed, and Merrimeg looked quite like a
giant beside him. She ran to him and stood over him and shook her
finger at him and said:
“What do you mean by mocking me all the time?”
“All the time?” said Little Hark, looking very much frightened.
“Yes, all the time!” said Merrimeg. “What do you mean by it?”
“Mean by it?” said the little Echo Dwarf.
“Don’t you dare repeat everything I say to you!” cried Merrimeg.
“You naughty thing, you’re mocking me!”
“You’re mocking me!” said Little Hark, beginning to cry.
“HOW DARE YOU SAY SUCH A THING? HOW DARE YOU?”
“Why, you awful little thing, I’m not!” cried Merrimeg. “How dare you
say such a thing? How dare you?”
“How dare you?” said Little Hark, crying harder.
This made Merrimeg very angry, so angry that she could not say
another word. She seized hold of Little Hark’s arm and shook him.
There she was shaking him, pretty hard too, and Little Hark was
bawling out loud, when Big Hark, his father, came out of the cave
and hurried towards them to see what was the matter.
Big Hark was very strong, though he was not very big. He threw his
arms around Merrimeg and dragged her away from Little Hark and
hauled her along to the cave and pulled her into it. Before she knew
it her arms were bound up tight with tough vines which Big Hark
had snatched down from the wall.
Big Hark made her sit down on the floor with her back against the
wall, and he and Little Hark stood before her. Little Hark looked at
his father and said:
“Kormsdee lokspit calliper?”
This meant, in the private language of the Echo Dwarfs, “What are
you going to do with her?”
“Lokspit meegs,” said Big Hark, “doomdog askbiddle beddagog
diskorfunjax krissmuss.”
This meant, “I am going to keep her here for seven Christmases, for
you to practice your echo lessons on.”
“Snexterbean?” asked Little Hark. This meant, “What then?”
“Lokspit snexter,” said Big Hark, “flambilly noformikin beskeem.” This
meant, as you may imagine, “I am then going to give her to the Fire
Bubbles at the back of the cave.”
Merrimeg tried to get her arms loose, and cried out:
“I want to go home! I want to go home!”
Big Hark nudged Little Hark, reminding him to practice his echo, and
Little Hark said:
“Go home!”
“All right, then, I will!” cried Merrimeg, and she struggled to her feet
and started to run towards the mouth of the cave. But Big Hark
caught her and held her, and she cried out:
“Let me go! Let me go!”
“Go!” said Little Hark, echoing her words, and Merrimeg cried:
“I can’t! He won’t let me!”
Now Little Hark should have said “Let me!” But he forgot all about
echoing her words, and he shouted out two words of his own.
“Run back!” he cried, and this was what gave Merrimeg her chance
to escape. For Big Hark was so angry at Little Hark’s forgetting to
echo back Merrimeg’s own words, and calling back words of his own
instead, which was strictly forbidden, that he let go of Merrimeg and
turned round on Little Hark and shook his finger at him and shouted,
“Let me! Oxtragob borgs, gooblik!” and boxed Little Hark’s ears with
all his might and main.
Little Hark broke out crying, and Merrimeg dashed away into the
dark at the back of the cave, and ran on faster and faster into the
darkness. Pretty soon she heard Big Hark shout out something in his
own language, and she knew that he was running after her. So she
ran on faster than before, and in a moment she struck against a wall
in the dark, and feeling it with her hands she turned a corner and
saw something which almost made her stop breathing.
It was a stream of sparkling red fire, running across the ground right
in her path.
As she looked at it, an enormous bubble, like a soap bubble, but
red-hot and shining like fire, rose from the stream and floated up in
the air towards her. She crouched down, and the Fire Bubble floated
up to the ceiling and burst with a loud crack and a shower of sparks;
and then another one rose from the stream and floated towards her
and broke against the ceiling; and then another and another, one
right after the other.
Merrimeg was frightened so that she couldn’t move. She didn’t dare
to go on, and she didn’t dare to go back. She heard the voice of Big
Hark behind her in the dark, crying out: “Sdig! sdig!” And at that
moment she——
Well, she heard another voice, from the other side of the Fire
Bubbles, and it said:
“I believe it is, brother, I believe it is.”
Merrimeg clapped her hands with joy and cried: “Here I am! Help
me! Help me!”
Big Hark’s voice behind her echoed her words, “Help me!” and the
other voice, on the far side of the Fire Bubbles, said:
“I suppose we’d better help her, brother Nibby.”
“I’m quite of your opinion, brother, quite,” said the voice of brother
Nibby.
“Quite,” said Big Hark, in echo, just behind Merrimeg. As he said this
he threw his arms around her and began to drag her back into the
cave. Little Hark came running up, and he tugged at his father’s coat
and said, “Skeems non doogdag, himpotter,” which meant, “Please
don’t hurt her, father.”
But he hadn’t any more than said these words than Malkin and
Nibby, the two gnomes, rushed across the stream of fire, knocking
the Fire Bubbles right and left with their hands, and Malkin picked up
Little Hark, slung him on his shoulder, and ran back with him across
the stream of fire, knocking the Fire Bubbles right and left as he ran.
“Ishkameerz! O ishkameerz!” cried Big Hark, and he let go of
Merrimeg and rushed down to the stream of fire, holding out his
hands towards the little boy on the other side. But he did not dare
go near the fire.
“I believe now maybe he’ll give her up,” said Malkin from the other
side of the fire.
“Give her up!” said Little Hark, struggling on Malkin’s shoulder.
“Fee skimble fen bitkin, fee skimble fen moklin!” shouted Big Hark,
which meant, “If you’ll give up the boy, I’ll give up the maiden!”
“Good!” cried Malkin.
“Good!” said Little Hark.
Nibby the gnome ran to Merrimeg and unfastened the vines that
bound her arms, and lifted her up and carried her across the stream
of fire, knocking the Fire Bubbles away with his hand, so that she
wasn’t harmed in the least; and at the same time brother Malkin
crossed the stream of fire and put down Little Hark beside his father.
“Hurry! hurry!” cried Merrimeg, and pulled the two gnomes away
into the darkness beyond the fire.
“Farewell!” cried Malkin.
“Good-by!” called back Little Hark, and his father shook him by the
shoulder and said, “Oxtragob borgs, gooblik!” which meant, as you
know, “Wrong again, stupid!”
“Take me home quick,” said Merrimeg as she went on between the
two gnomes deeper and deeper into the darkness.
“She’s not very polite to-day, brother,” said Malkin.
“Not very, brother, not very, indeed,” said Nibby. “She really ought to
say ‘Please,’ I think.”
“Maybe something’s happened to bother her,” said Malkin.
“Maybe so, maybe so,” said Nibby. “I wonder what it could be.”
They went down into the earth for a long way, and then they went
up under the earth for a long way, and at last they stopped.
“Here we are, brother Nibby,” said Malkin, and he appeared to be
opening a door.
“Home again, brother Malkin,” said Nibby, and the three of them
climbed a ladder, and Nibby raised a door overhead, and the next
minute they were in the gnomes’ kitchen.
Malkin and Nibby sat themselves down at their little table, where a
candle was burning, and Malkin said:
“I suppose we’d better ask her to stay to supper, brother.”
“Just what I was thinking,” said Nibby. “But which one of us will ask
her?”
“Oh, you must be the one to do that, brother.”
“Oh, no, you can do it so much better, brother Malkin. You must——”
“Goodness gracious me!” said Merrimeg. “You don’t need to ask me.
I can’t stay anyway.”
“Not very polite to-day, brother, not very polite,” said Malkin.
“I’m afraid not, brother, I’m afraid not,” said Nibby.
“Oh, I’m so sorry,” said Merrimeg. “Please excuse me. I really have
to go home. And I’m ever so much obliged to you.”
She climbed the ladder to the ceiling and went up through the little
door there, and calling down good-by she stepped out onto the roof
of the gnomes’ house, and closed down the door after her.
She ran as fast as she could through the woods, until she came to
the brook where she had left her basket. There it was, full of water
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
Let us accompany you on the journey of exploring knowledge and
personal growth!
ebookultra.com

More Related Content

Similar to ASP NET Professional Projects 1st Edition Hersh Bhasin (20)

PDF
01 web 2.0 - more than a pretty face for soa
Technology Transfer
 
PDF
Immediate access to Microsoft ASP NET coding strategies with the Microsoft AS...
ellzylofty1i
 
PDF
Building Web Apis With Aspnet Core Meap Version 11 All 12 Chapters Valerio De...
anjumlehde00
 
PDF
Microsoft ASP NET coding strategies with the Microsoft ASP NET team Matthew G...
trufincalgua
 
DOCX
E-PORTAL OF COLLAGE
mallikarjun biradar
 
DOCX
E-COMMERCE-PPROJECT-REPORT FOR ALL DESIGN AND ASSCESSORIES MAKE A REPORT
Rai University
 
PPT
Aspnet2.0 Introduction
ChanHan Hy
 
PPTX
X internet framework
Neha Malik
 
PDF
Presemtation Tier Optimizations
Anup Hariharan Nair
 
PDF
IRJET- Creating Website as a Service using Web Components
IRJET Journal
 
PDF
Mastering ASP NET with Visual C 1st Edition A. Russell Jones
gezanejerzu
 
PDF
ASP.NET Web API Interview Questions By Scholarhat
Scholarhat
 
DOCX
E commerce
john1234calvin
 
DOCX
Beginners introduction to asp.net
Naveen Kumar Veligeti
 
DOCX
report_vendor_connect
Yash Mittal
 
PDF
Making Of PHP Based Web Application
Sachin Walvekar
 
PPTX
Industrial training project ppt of online shopping
anil kumar
 
PPT
Web engineering 2(lect 0)
Roohul Amin
 
DOCX
Online fast food django.docx
vidhi184862
 
PDF
Mastering ASP NET with Visual C 1st Edition A. Russell Jones
llancojenem63
 
01 web 2.0 - more than a pretty face for soa
Technology Transfer
 
Immediate access to Microsoft ASP NET coding strategies with the Microsoft AS...
ellzylofty1i
 
Building Web Apis With Aspnet Core Meap Version 11 All 12 Chapters Valerio De...
anjumlehde00
 
Microsoft ASP NET coding strategies with the Microsoft ASP NET team Matthew G...
trufincalgua
 
E-PORTAL OF COLLAGE
mallikarjun biradar
 
E-COMMERCE-PPROJECT-REPORT FOR ALL DESIGN AND ASSCESSORIES MAKE A REPORT
Rai University
 
Aspnet2.0 Introduction
ChanHan Hy
 
X internet framework
Neha Malik
 
Presemtation Tier Optimizations
Anup Hariharan Nair
 
IRJET- Creating Website as a Service using Web Components
IRJET Journal
 
Mastering ASP NET with Visual C 1st Edition A. Russell Jones
gezanejerzu
 
ASP.NET Web API Interview Questions By Scholarhat
Scholarhat
 
E commerce
john1234calvin
 
Beginners introduction to asp.net
Naveen Kumar Veligeti
 
report_vendor_connect
Yash Mittal
 
Making Of PHP Based Web Application
Sachin Walvekar
 
Industrial training project ppt of online shopping
anil kumar
 
Web engineering 2(lect 0)
Roohul Amin
 
Online fast food django.docx
vidhi184862
 
Mastering ASP NET with Visual C 1st Edition A. Russell Jones
llancojenem63
 

Recently uploaded (20)

PPTX
Digital Professionalism and Interpersonal Competence
rutvikgediya1
 
PPTX
HERNIA: INGUINAL HERNIA, UMBLICAL HERNIA.pptx
PRADEEP ABOTHU
 
PPTX
Introduction to pediatric nursing in 5th Sem..pptx
AneetaSharma15
 
PPTX
Electrophysiology_of_Heart. Electrophysiology studies in Cardiovascular syste...
Rajshri Ghogare
 
PPTX
DIARRHOEA & DEHYDRATION: NURSING MANAGEMENT.pptx
PRADEEP ABOTHU
 
PPTX
IDEAS AND EARLY STATES Social science pptx
NIRANJANASSURESH
 
PPTX
Cybersecurity: How to Protect your Digital World from Hackers
vaidikpanda4
 
PPTX
Various Psychological tests: challenges and contemporary trends in psychologi...
santoshmohalik1
 
PDF
EXCRETION-STRUCTURE OF NEPHRON,URINE FORMATION
raviralanaresh2
 
PPTX
INTESTINALPARASITES OR WORM INFESTATIONS.pptx
PRADEEP ABOTHU
 
PPTX
Command Palatte in Odoo 18.1 Spreadsheet - Odoo Slides
Celine George
 
PPTX
GENERAL METHODS OF ISOLATION AND PURIFICATION OF MARINE__MPHARM.pptx
SHAHEEN SHABBIR
 
PPTX
THE HUMAN INTEGUMENTARY SYSTEM#MLT#BCRAPC.pptx
Subham Panja
 
PPTX
Constitutional Design Civics Class 9.pptx
bikesh692
 
PPTX
The Future of Artificial Intelligence Opportunities and Risks Ahead
vaghelajayendra784
 
PDF
FULL DOCUMENT: Read the full Deloitte and Touche audit report on the National...
Kweku Zurek
 
PPTX
Joint Mobility : Fundamentals of Joint Mobility
Sreeraj S R
 
PPTX
Artificial Intelligence in Gastroentrology: Advancements and Future Presprec...
AyanHossain
 
PPTX
Nutrition Quiz bee for elementary 2025 1.pptx
RichellMarianoPugal
 
PPTX
TOP 10 AI TOOLS YOU MUST LEARN TO SURVIVE IN 2025 AND ABOVE
digilearnings.com
 
Digital Professionalism and Interpersonal Competence
rutvikgediya1
 
HERNIA: INGUINAL HERNIA, UMBLICAL HERNIA.pptx
PRADEEP ABOTHU
 
Introduction to pediatric nursing in 5th Sem..pptx
AneetaSharma15
 
Electrophysiology_of_Heart. Electrophysiology studies in Cardiovascular syste...
Rajshri Ghogare
 
DIARRHOEA & DEHYDRATION: NURSING MANAGEMENT.pptx
PRADEEP ABOTHU
 
IDEAS AND EARLY STATES Social science pptx
NIRANJANASSURESH
 
Cybersecurity: How to Protect your Digital World from Hackers
vaidikpanda4
 
Various Psychological tests: challenges and contemporary trends in psychologi...
santoshmohalik1
 
EXCRETION-STRUCTURE OF NEPHRON,URINE FORMATION
raviralanaresh2
 
INTESTINALPARASITES OR WORM INFESTATIONS.pptx
PRADEEP ABOTHU
 
Command Palatte in Odoo 18.1 Spreadsheet - Odoo Slides
Celine George
 
GENERAL METHODS OF ISOLATION AND PURIFICATION OF MARINE__MPHARM.pptx
SHAHEEN SHABBIR
 
THE HUMAN INTEGUMENTARY SYSTEM#MLT#BCRAPC.pptx
Subham Panja
 
Constitutional Design Civics Class 9.pptx
bikesh692
 
The Future of Artificial Intelligence Opportunities and Risks Ahead
vaghelajayendra784
 
FULL DOCUMENT: Read the full Deloitte and Touche audit report on the National...
Kweku Zurek
 
Joint Mobility : Fundamentals of Joint Mobility
Sreeraj S R
 
Artificial Intelligence in Gastroentrology: Advancements and Future Presprec...
AyanHossain
 
Nutrition Quiz bee for elementary 2025 1.pptx
RichellMarianoPugal
 
TOP 10 AI TOOLS YOU MUST LEARN TO SURVIVE IN 2025 AND ABOVE
digilearnings.com
 
Ad

ASP NET Professional Projects 1st Edition Hersh Bhasin

  • 1. ASP NET Professional Projects 1st Edition Hersh Bhasin download https://ebookultra.com/download/asp-net-professional- projects-1st-edition-hersh-bhasin/ Explore and download more ebooks or textbooks at ebookultra.com
  • 2. We believe these products will be a great fit for you. Click the link to download now, or visit ebookultra.com to discover even more! Professional ASP NET Design Patterns Scott Millett https://ebookultra.com/download/professional-asp-net-design-patterns- scott-millett/ Professional ASP NET MVC 4 1st Edition Jon Galloway https://ebookultra.com/download/professional-asp-net-mvc-4-1st- edition-jon-galloway/ Professional ASP NET MVC 3 1st Edition Jon Galloway https://ebookultra.com/download/professional-asp-net-mvc-3-1st- edition-jon-galloway/ Professional ASP NET 2 0 XML Thiru Thangarathinam https://ebookultra.com/download/professional-asp-net-2-0-xml-thiru- thangarathinam/
  • 3. Professional IIS 7 and ASP NET Integrated Programming Dr. Shahram Khosravi https://ebookultra.com/download/professional-iis-7-and-asp-net- integrated-programming-dr-shahram-khosravi/ Pro Telerik ASP NET and Silverlight Controls Master Telerik Controls for Advanced ASP NET and Silverlight Projects 1st Edition José Rolando Guay Paz (Auth.) https://ebookultra.com/download/pro-telerik-asp-net-and-silverlight- controls-master-telerik-controls-for-advanced-asp-net-and-silverlight- projects-1st-edition-jose-rolando-guay-paz-auth/ ASP NET AJAX programmer s reference with ASP NET 2 0 or ASP NET 3 5 Dr. Shahram Khosravi https://ebookultra.com/download/asp-net-ajax-programmer-s-reference- with-asp-net-2-0-or-asp-net-3-5-dr-shahram-khosravi/ Professional ASP NET 3 5 in C Sharp and Visual Basic Bill Evjen https://ebookultra.com/download/professional-asp-net-3-5-in-c-sharp- and-visual-basic-bill-evjen/ ASP NET Bible 1st Edition Mridula Parihar https://ebookultra.com/download/asp-net-bible-1st-edition-mridula- parihar/
  • 5. ASP NET Professional Projects 1st Edition Hersh Bhasin Digital Instant Download Author(s): Hersh Bhasin ISBN(s): 9781931841214, 1931841217 Edition: 1 File Details: PDF, 4.42 MB Year: 2002 Language: english
  • 6. Microsoft ASP.NET Professional Projects by Hersh Bhasin ISBN: 1931841217 Premier Press © 2002 (638 pages) Teaches Web developers how to build powerful applications using the .NET Framework and Microsoft’s ASP.NET. Table of Contents Microsoft ASP.NET Professional Projects Part I - The ASP.NET Programming Environment Chapter 1 - Introducing ASP.NET Chapter 2 - Introducing ASP.NET Web Forms and Controls Chapter 3 - Using ADO.NET in the .NET Framework Chapter 4 - Data Binding Chapter 5 - Input Validation Chapter 6 - User Controls Chapter 7 - Custom Controls Chapter 8 - Business Objects Chapter 9 - Working with ASP.NET Web Services Chapter 10 - ASP.NET Applications Chapter 11 - Caching Chapter 12 - Tracing Chapter 13 - Security Part II - Projects Project 1 - A Personal Finance Manager Chapter 14 - The Design of the Personal Finance Manager Chapter 15 - Chart of Accounts Chapter 16 - Transactions Chapter 17 - The Trial Balance Report Project 2 - Web Services Chapter 18 - Creating a Generic Database Web Service Chapter 19 - Designing a Navigation System Chapter 20 - Incorporating Web Services in the Chart of Accounts Form Chapter 21 - Incorporating Web Services in the Transactions Form Chapter 22 - Incorporating Web Services in the Trial Balance Project 3 - Inventory Management System Chapter 23 - The Design of the Inventory Management System Chapter 24 - Inventory Masters Chapter 25 - Inventory Movements Chapter 26 - The Inventory Balances Report Project 4 - The GenEditAdd Control Chapter 27 - Using the GenEditAdd Control Chapter 28 - Extending the GenEditAdd Control Project 5 - Visual Studio.NET Chapter 29 - Displaying Database Data Using a Strongly-Typed DataSet Chapter 30 - Writing CRUD Applications with Visual Studio.NET Chapter 31 - Creating a Web Service Using Visual Studio.NET Part III - Appendixes Appendix A - Installing the Sample Database Appendix B - HailStorm
  • 7. Index List of Figures List of Tables List of Examples Microsoft ASP.NET Professional Projects Hersh Bhasin © 2002 by Premier Press, Inc. All rights reserved. No part of this book may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system without written permission from Premier Press, except for the inclusion of brief quotations in a review. The Premier Press logo, top edge printing, related trade dress and Professional Projects are trademarks of Premier Press, Inc. and may not be used without written permission. All other trademarks are the property of their respective owners. Important: Premier Press cannot provide software support. Please contact the appropriate software manufacturer's technical support line or Web site for assistance. Premier Press and the author have attempted throughout this book to distinguish proprietary trademarks from descriptive terms by following the capitalization style used by the manufacturer. Information contained in this book has been obtained by Premier Press from sources believed to be reliable. However, because of the possibility of human or mechanical error by our sources, Premier Press, or others, the Publisher does not guarantee the accuracy, adequacy, or completeness of any information and is not responsible for any errors or omissions or the results obtained from use of such information. Readers should be particularly aware of the fact that the Internet is an ever-changing entity. Some facts may have changed since this book went to press. ISBN: 1-931841-21-7 Library of Congress Catalog Card Number: 2001096478 Printed in the United States of America 02 03 04 05 06 RI 10 9 8 7 6 5 4 3 2 1 Publisher Stacy L. Hiquet Associate Marketing Manager Heather Buzzingham Managing Editor Sandy Doell Acquisitions Editor Kevin Harreld Editorial Assistant Margaret Bauer Technical Reviewer Mingyong Yang Copy Editor Jenny Davidson Interior Layout Marian Hartsough Associates Cover Design Phil Velikan Indexer Kelly Talbot Proofreader Kim Cofer Dedication To my parents, my wife Ritu, and my daughter Ria Acknowledgments I thank my wife Ritu for motivating me to write this book and for painstakingly proofreading, editing, and formatting all my manuscripts. I thank all my friends at Premier Publishing who made this book possible. Thank you Kevin Harreld and Jody Kennen for putting your trust in me, Elizabeth Agostinelli, Jenny Davidson and Brian Thompson for
  • 8. wading through my work and fixing what was wrong and Mingyong Yang for reviewing my source code and giving valuable suggestions. About the Author Hersh Bhasin has been consulting on Microsoft technologies for some nine odd years and maintains a Web site on emerging technologies like .NET, SOAP, XML at http://hersh.weblogs.com. He qualified as a Management Accountant from The Chartered Institute of Management Accountants - UK (CIMA) and also obtained a Bachelor of Science degree from the University of Punjab, India. He can be contacted at [email protected] Part I: The ASP.NET Programming Environment Chapter List Chapter 1: Introducing ASP.NET Chapter 2: Introducing ASP.NET Web Forms and Controls Chapter 3: Using ADO.NET in the .NET Framework Chapter 4: Data Binding Chapter 5: Input Validation Chapter 6: User Controls Chapter 7: Custom Controls Chapter 8: Business Objects Chapter 9: Working with ASP.NET Web Services Chapter 10: ASP.NET Applications Chapter 11: Caching Chapter 12: Tracing Chapter 13: Security Chapter 1: Introducing ASP.NET Overview ASP.NET is a radical evolution of ASP and its associated data access service, ADO, which is now called ADO.NET. ASP suffered from many limitations—it was unstructured, so the code intermingled with the presentation logic, which made applications difficult to understand and maintain. Due to this limitation of ASP, code segregation was not possible. You could not hand over the presentation logic to a Web designer and the code to a developer and ask both to work simultaneously on the application. Unlike windows- based application development, ASP did not have an inherent component or programming model. ASP developers had to use a combination of markup languages, scripting environments, and server platforms to get their work done. Tool support was limited and although Visual InterDev introduced a Visual Basic type interface that allowed you to drag and drop components such as text boxes and labels onto a form, it was clunky and added tons of code to the form, which needless to say scared away most developers from ever using this product. ADO, the Data Access component of ASP, had been designed with a view to serving the data access needs of client/server-based applications. Programming for the Web, however, followed different rules. A client/server application had no need to optimize database connections and a typical database operation would open a database connection and leave it open until the looping operation of an ADO recordset was complete. Database connections in a Web-based environment, however, were expensive. Web programming required a disconnected way of manipulating data. Thus the Remote Data Services (RDS) were born. With the advent of XML (eXtensible Markup Language), the request/response paradigm became the order of the day. To keep up with this message-based system of communication, HTTP support was added to RDS, which allowed business logic to be called at the middle tier. XML follows a
  • 9. heterogeneous and hierarchical data model (XMLDOM) whereas MDAC (Microsoft Data Access Technologies) follows a relational model. To work with XML data we had to make a choice between MSXML and MDAC. But ADO.NET solves this dilemma. XML support is built at a very basic level and it is quite similar to working with "database" data. No longer is choosing between MDAC and MSXML an issue. Web forms, which will be discussed in Chapter 2, "Introducing ASP.NET Web Forms and Controls," are the fundamental building blocks of ASP.NET. The concept of "Code Behind" has been introduced, which is the process of writing pres entation logic and script in separate files. Code Behind seeks to eliminate the clutter and "spaghetti" code (spaghetti code is code where the scripting portion intermingles with the presentation logic) that traditional ASP seemed to encourage. ASP.NET provides a server-based, event-driven programming model similar to Visual Basic, which enables WYSIWYG tools like Visual Studio to be used. ASP.NET introduces two sets of controls, the HTML controls and the Web controls, which are collectively known as "server controls." These controls render HTML for Web browsers in addition to providing means of preserving state across round trips, detecting the browser types (and rendering HTML accordingly), and serving as the building blocks for composite controls. These controls reside on the server and output plain HTML to the browser. Since all browsers can understand HTML, they are able to overcome the classic cross-browser compatibility problem. The HTML controls (textbox, form, button, and so on) are the normal HTML controls that we have been using so far, with a new runat="server" attribute added. The sole use of these controls is to provide a quick migration path to ASP.NET as any HTML control can be converted to an ASP.NET control by adding the runat="server" attribute. The Web controls, however, provide a high degree of abstraction and usefulness. Four types of Web controls exist: Intrinsic controls, Rich controls, List Bound controls, and Validation controls. Intrinsic controls are the ASP.NET versions of traditional HTML controls, such as textboxes, buttons, and DropDownList. These controls have a special prefix of ASP.NET that distinguishes them from the normal HTML controls and they also have a runat ="server" attribute. Thus a textbox is created as follows: <asp:TextBox id="Text1" runat="server"/> The purpose of Web controls is to simplify the nomenclature of a control. Controls that overlapped in their functionality have been reduced to a single control. Properties like ForeColor, Font, BackColor, Enabled, and so on are consistent among controls. The developer thus needs to remember one property setting that he can apply to all controls. Rich controls consist of the Calendar and AdRotator. The Calendar outputs HTML for downlevel browsers (these are browsers that do not support DHTML) or DHTML for uplevel browsers. The AdRotator displays rotating advertisements. List bound controls are the subject matter of Chapter 4, "Data Binding." There are three controls in this category: the DataGrid, the DataList and the DataRepeater. These controls automate the task of displaying database data as lists and data grids. The developer applies a number of templates to these controls to achieve a high degree of customization. The DataGrid can even be used for in-place editing of data. Validation controls, which are discussed in Chapter 5, "Input Validation," automate the mundane activity of writing validation code. There are five validation controls and one validation summary control. The validation controls are the RequiredFieldValidator, RegularExpressionValidator, CompareValidator, RangeValidator, CustomValidator, and the ValidationSummary. The work of each of these controls is evident from its name. For example, the RequiredFieldValidator does not allow the user to leave the required field blank. Similarly, the RangeValidator verifies whether user input falls within a specified range. It is a simple task to incorporate validation in an ASP.NET web form. All you need to do is associate an input text box with the appropriate validation control. ADO.NET, the latest avatar of ADO, is discussed in Chapter 3, "Using ADO.NET in the .NET Framework." ADO has seen a massive overhaul (a complete rewrite would be a better choice of words) in ADO.NET. The foundation of ADO—the recordset—has been given the golden handshake. As noted above, the recordset understood only the
  • 10. relational way of doing things, which was appropriate for handling database data. With the advent of XML, which followed a heterogeneous and hierarchical data model, the recordset had a hard time keeping up. A new object called the DataSet has been introduced in ASP.NET. The DataSet is an in-memory copy of the database, complete with tables, columns, relationships, constraints, and data. It allows relationships to exist between multiple tables, analogous to a foreign-key relationship in a database. You can navigate between tables based upon their relationships. The DataSet has some outstanding qualities. For example, it can talk to a variety of datasources; it can receive data from a database, an XML file, code, or user input. No matter what the source of the data within the DataSet is, it is manipulated through the same set of standard APIs. The DataSet is transmitted as an XML stream and can thus be passed between any objects (not just COM objects) without interference from firewalls. To transmit an ADO disconnected recordset from one component to another, COM marshalling had to be used. User controls, which are discussed in Chapter 6, "User Controls," are the evolution of the server-side include files. Include files are static files. User controls, on the other hand, provide object model support, which enables you to program against properties and use methods. User controls work much like the ASP intrinsic controls in that they can expose properties and methods. In Chapter 6, I design a user control that automates building of the navigation links for a Web site based on the URLs specified in an XML file. ASP.NET has a very clean and elegant approach to authoring custom controls. In Chapter 7, "Custom Controls," I discuss the process of authoring custom controls in detail. I also show you how to build a component (which I call "GenEditAdd") that you can use to extend the DataGrid's functionality. The DataGrid does not have the functionality to insert records. Using the GenEditAdd component, you can automate the process of record insertion. You can also use the GenEditAdd component in lieu of the editing functionality provided by the DataGrid, which requires you to code a number of events. The GenEditAdd component requires simple property settings and the code generation is automatic. Encapsulating business logic into components has always been an important part of both Web and client/server applications. ASP.NET has greatly simplified the process of registering components. If you have developed COM objects in the past, you must know the pain involved in registering components. A component had to be registered using the regsvr32 utility. If the component was modified, the entire Web server had to be stopped in order to re-register the component. This was called "DLL Hell." In ASP.NET, components are simply copied and pasted in the bin directory and no registry updates are required. Chapter 8, "Business Objects," looks at this important topic. Web service is the main protagonist of the .NET arena and the content of this book and its projects reflect its importance. A web service is a combination of three things: a function written in a .NET-compliant language, SOAP, and XML. When you need to reuse logic in a number of places, the best way to do so is to write the code as a function. A collection of functions that share some common goal can be combined into a business object. For example, the four basic database operations are insert, delete, update, and select. We can write a generic function for each operation and pack them together in a business object called (say) DataBaseClass. Now this class, together with its functions, can be initiated and called in any object that needs to use its functionality. A web service is a Web-enabled business object, which is a collection of functions that can be called over the Web. Functions written for a web service are written as normal functions, and the only difference is that the functions are preceded with a special tag that marks them as web services. A standard called SOAP (Simple Object Access Protocol) sets out the rules that must be followed by the machine that makes a function call and the machine that responds to that call by sending a resultset back. The request and response is made in XML and the XML document follows the rules set out in the SOAP standard. Exchanging information as XML enables a client application to call a function on the server, regardless of what operating system each is running, what programming language each is written in, or what component model is supported on each. This is because XML is basically a text file that all machines can understand and because SOAP uses HTTP, which is the most common Internet transfer protocol and
  • 11. one that is used by essentially all Web browsers. Chapter 9 "Working with ASP.NET Web Services," provides a detailed discussion on web services. Chapter 10, "ASP.NET Applications," covers ASP.NET applications. An ASP.NET application is an IIS virtual directory and its subdirectories. All of your Web application files go into this folder. This folder has a special subdirectory called bin. All the compiled business objects and web services reside here. When you want to register a new component, you just copy and paste the DLL file in this folder (as opposed to using regsvr32). This folder also contains two special files: web.config and global.asax. The web.config file is an XML file that you use to configure various facets of the application. For example, you can use it to set up and configure security, caching, or tracing. The global.asax file contains application-level program directives, handlers for application and session-level events, and declarations of objects that are globally accessible to all parts of the application. In general, this file enhances the functionality that was provided by the global.asa file in ASP. Chapter 11, "Caching," deals with caching, which is the process of keeping frequently visited Web pages in memory. The theory behind caching is that there are some items of the Web site that are very expensive to construct and that such items should be created once and then stashed away in memory for a fixed duration of time or until they change. Subsequent calls to these resources will not re-create the resource but simply retrieve it from the cache. Such items are typically resources that remain unchanged over a period of time; for example, shopping lists or price lists. Chapter 12, "Tracing," discusses tracing. Developers have often resorted to writing a number of Response.Write() statements in the code to try to debug errant code. When the problem is located, these debugging statements must be cleared out. This method is cumbersome and error-prone, because you might accidentally remove code along with the debugging statements. ASP.NET introduces an elgant way of writing such debugging code. Debugging is enabled by adding a page-level directive (or by enabling it in the web.config file). Debugging statements are then written using Trace.write() instead of Response.Write(). When the form has been debugged, there is no need to remove these statements from the body of the form. You can simply disable Trace and these statements will not be displayed in the browser. Security is discussed in Chapter 13. ASP.NET implements authentication through authentication providers. These authentication providers are modules that contain code required to authenticate the credentials of the requesting user. Three authentication providers are currently available: Windows Authentication, Passport Authentication, and Cookie Authentication. All three providers are discussed. In Project 1 (Chapters 14 to 17), I show you how to build a Web-enabled personal finance manager using ASP.NET web forms. This project is spread over four chapters. In this project, I take a product that has its roots in the client/server era—a personal finance accounting module—and revamp it for the Web. A personal finance manager is an accounting application, such as Quicken or Microsoft Money that enables you to maintain bank, cash, credit cards, and investment accounts. This project is designed to be a production quality accounting application and makes use of stored procedures and database triggers. It's comprised of web forms to maintain your chart of accounts, transactions details and it even draws up a trial balance report. The Internet brings some exciting possibilities to the traditional way of designing applications. The various modules of an accounting application need no longer be connected with "wire." Using ASP.NET and web services, we can design applications that can send and receive data using the Internet and HTTP. In Project 2 (which spreads over five chapters), I build generic database access services that can then be used to interact with any database. This service has functionality to insert, update, delete, and select records from a database. This web service accepts a database connection and a valid SQL query as parameters. If the query is an action query (insert, update, or delete), the appropriate action is performed. If the query is a select query (which returns a resultset), a DataSet is returned to the calling object. This DataSet can then be used to bind a control like a DataGrid. I demonstrate this service by incorporating it in the personal finance manager that was developed in Project 1. This project also demonstrates use of the navigation user control that was built in Chapter 6, "User Controls." This navigation control builds the site navigation of the application using URLs defined in an XML file.
  • 12. The advantage of having a navigation system separate from the main application is that you can add or delete links (by modifying the XML file) without having to change the Web pages in the application. In Project 3 (Chapters 23 to 26), I have taken another application that has traditionally been a client/server application and revamped it for the Web. This is an inventory management application. This application makes use of the database web service class that was developed in Project 2. It also makes use of various stored procedures and triggers. In Project 4 (Chapters 27 and 28), I enhance the functionality of the custom control GenEditAdd (which was initially developed in Chapter 7). The GenEditAdd control can be used to insert or update database records. The DataGrid does not have the capability to insert records, although it does have editing capabilities. The edit mode of the DataGrid is quite cumbersome, as you have to code a number of events in the DataGrid for the process to work. This control was developed to enhance the usefulness of the DataGrid. It can be hooked up to a DataGrid to provide both editing and insertion capabilities in a consistent manner. This control works by setting various properties and the code generation is automated. In Project 5 (Chapters 29 to 31), I discuss the important features of Visual Studio. In Chapter 29, "Displaying Database Data Using a Strongly-Typed DataSet," I begin with an overview of the important features of Visual Studio.NET, focusing on the various wizards, tools and components available. I'll also show you how to use the typed DataSet to display database information using the Visual Studio.NET drag and drop features. In Chapter 30, "Writing CRUD Applications with Visual Studio.NET," I'll show you how to interact with the database using Visual Studio.NET. I'll show you how to add, delete, and update database rows. I'll also show you how to customize a DataGrid by enabling paging and sorting from within the Visual Studio.NET. Finally, in Chapter 31, "Creating a Web Service Using Visual Studio.NET," I'll show you how to develop and consume web services with Visual Studio.NET. Installing the .NET Framework SDK The .NET SDK can be downloaded from the Microsoft download site at http://msdn.microsoft.com/net/. It is quite a large download and you might want to consider ordering a CD, which will ship at a nominal charge. There are two versions available; a standard version or a premium version. The premium version includes additional features like output caching, web farm session state, code access hosting and support for four and above CPUs. Installation is straightforward and involves running the setup.exe. If prompted, you should update the Windows Installer Components. You should also apply the latest patches for your Windows version. You should also update your version of MDAC (Microsoft Data Access Components) to the latest version, which is currently version 2.7. If the installer complains that ADO 2.7 is not installed, you can still proceed with the installation by disregarding the complaint. You will be given a choice to install the SDK samples. The samples are a rich source of information and you should choose to install them. A named instance of the Microsoft Data Engine (MSDE) is installed along with the samples and this contains the sample database. Tip A limited-time evaluation copy of Microsoft SQL Server can be obtained from http://www.microsoft.com/sql/evaluation/trial/2000/default.asp. You can also order this copy on a CD and only pay the cost of shipping. After you have SQL Server up and running, install the ASP.NET QuickStart samples. These samples are an excellent training resource on ASP.NET. To install these samples, open the Microsoft NET Framework SDK/Samples and QuickStart Tutorials link, which is added to your programs during the SDK installation and follow the installation steps. Once the samples are installed, they can be accessed at http://localhost/quickstart/default.aspx.
  • 13. After you install the SDK, all you need is a text editor to write your scripts. You can also order the Visual Studio CD set (again at a nominal charge) and use it to develop your scripts. If you have the Visual Studio CDs, the Framework SDK is on the second CD. I have discussed development with Visual Studio, where appropriate, and one entire project (Project 5) is dedicated to exploring this development tool. I have left discussion of Visual Studio till the end because I want my readers to be familiar with the internals of ASP.NET before using the wizard-like tools of the Visual Studio IDE, which hides the intricacies of code development. A text editor that I highly recommend is TextPad, which is shareware and available at http://www.textpad.com. You can also download the syntax definition file for .NET from its site. This file will display various ASP.NET keywords in different colors. Chapter 2: Introducing ASP.NET Web Forms and Controls ASP.NET forms are designed to overcome a number of shortcomings inherent in ASP pages. In these pages the HTML elements and script code are necessarily intertwined making the resultant page very cluttered. These pages are not easily edited with WYSIWYG tools. ASP.NET improves on the ASP page and adds many interesting enhancements to it. It provides a server-based, event-based programming model similar to Visual Basic. It introduces a technique called "Code Behind," which allows the developer to keep the script code in a file separate from the HTML markup. ASP.NET introduces two sets of controls, the HTML controls and the Web Controls, which are collectively known as "server controls." These controls render HTML for Web browsers in addition to providing means of preserving state across round trips, detecting the browser types (and rendering HTML accordingly), and serving as the building blocks for composite controls. A round trip occurs whenever the user submits a form or an event occurs that causes a post to the server; for example, the user fills out a text box on a form and clicks on the submit button. The server processes the information passed onto it and sends the page back to the client for display. The original state of the form is maintained by ASP.NET. This means that when the user fills out a text box and submits the form to the server, the text box will retain this information even after the round trip. This is a welcome change from traditional ASP programming where the developer had to take care of maintaining state, as the user-input values were lost after every post. Basic Techniques To create an ASP.NET form you simply save a text or HTML file with the .aspx extension. No special tools are needed and you can use an editor like Notepad for the job. You can also use Visual Studio.NET, a rapid application development environment (RAD) that allows you to drag and drop controls onto a form. ASP.NET forms also provide selective backward compatibility. For example, you can use normal ASP code and mix script tags with HTML elements using the <% %> blocks. ASP and ASP.NET applications can run side by side on the IIS without interference. However ASP applications developed using the Visual Basic Scripting Edition will need to be modified to port to ASP.NET. In ASP.NET, script blocks are compiled and not interpreted, leading to enhanced performance. Compiling the code involves converting the code instructions to the machine language. In ASP.NET however, code is not compiled to machine language directly. It is instead compiled to an intermediate language called Microsoft Intermediate Language (MSIL or IL). IL code is further compiled to machine language using the JIT compiler (just-in-time compiler). The JIT compiler compiles each portion of code as it is called, instead of compiling the complete application in one go. This leads to faster start - up time. The resultant compiled code is stored till the application exits and hence does not have to be recompiled each time that portion of code gets called. Using this process, it is expected that execution of IL code will be almost as fast as executing native machine code.
  • 14. State Management Though you can use the script blocks, they do not lead themselves to a clean programming environment. Consider the basic requirement of maintaining state in a "post back" form. This is a form that accepts user input and "posts back" to itself. It needs to remember the values entered so that, if the user makes a mistake, it can display the values the user had earlier entered so that he can correct them. Coding for such a form in the ASP environment has involved using the Response object to extract the value and a <% =some variable %> block to display the passed value. Here is an example: State.asp <html> <form method="post"> <br> <h3> Name: <input name="Name" type=text value="<%=Request.form("Name")%>"> <br> <input type = "submit" value = "Submit"> </form> </html> In ASP.NET, state management is enabled automatically when you use server controls within a form control as follows: State.aspx <html> <body style="background-color='beige'; font-family='verdana'; font-size='10pt'"> <form method="post" runat=server> <h3> Name: <asp:textbox id="Name" runat="server"/> <asp:button text="Lookup" runat="server"/> </form> </body></html> Note that the form automatically "remembers" input values. There are a few drawbacks associated with using server controls for state management. You can only use the "post" method and can only have a single form on your page.
  • 15. Page Events ASP.NET has object orientation at its heart. You can code various events in a Visual Basic–like manner. As the form loads, the Page_Load event is fired, form controls become available for use and, as the user continues to interact with the form, other events are generated. The form unload event occurs when the page is unloaded. Due to this event-based structure, a developer can finally start applying event-based coding techniques to Web applications. Figure 2.1 shows you how to accept user-input values to perform a calculation using these techniques. Figure 2.1: Page Events. Events.aspx <%@ Page Language="vb" %> <html> <head> <script Runat="server"> Sub Calculate(src As Object, e As EventArgs) Amount.Text = Cstr(cint(qty.text)*cint(price.text)) End sub </script> </head> <body style="background-color='beige'; font-family='verdana'; font-size='10pt'"> <h4> Page Events </h4> <form method="POST" runat="server">
  • 16. Qty:<asp:TextBox id="Qty" Runat="server"/> Price: <asp:TextBox id="Price" Runat="server"/> Amount:<asp:TextBox id="Amount" ReadOnly = "true" Runat="server"/> <asp:Button id="btnCalculate" Text="Calculate" OnClick="Calculate" Runat="server"/><br> </form> </body> </html> At the top of the page, I specify that we are going to be using Visual Basic as the scripting language with the @ Page Language declaration. Each object can be assigned an id property. This enables me to extract property values for the object using its id property. In this example, I am accessing the text property for the Price and Qty textboxes instead of accessing the posted data using the response object. I put my code in the OnClick event of the button, thus making use of the new event-based paradigm of ASP.NET. Finally, note how I am able to set the ReadOnly property of the Amount textbox simply by setting its property value to "true". Code Behind As mentioned earlier, a major limitation of ASP is the way the script code intermingles with the HTML tags. This makes the separation of content from presentation difficult. The page becomes difficult to maintain and, in shops where developers and designers work together, segregation of tasks becomes impossible. Code Behind is a technique to separate the content from the script. A form can become really cluttered with script code and html tags. To reduce this clutter you can lift out all the script code from a web form and put it in a separate file. If you are using Visual Basic code, this file will have an extension of .vb and if you are using C#, .cs. The first thing you do in a Code Behind file is to import namespaces. This is the first construct in the Code Behind file. Namespaces can be thought of as including references in a Visual Basic project. When you make a reference to a DLL in Visual Basic, you can access the methods contained in that DLL. Similarly, by importing a namespace, you can access all the functionality residing within that namespace in your web form. If you do not use this declaration, you have to provide a fully qualified path when referring to a method residing in a particular namespace. This fully qualified path name can become very long (and a pain to type). Using the import directive allows you to directly refer to the method by name. Here are some of the commonly used Namespaces: § The System namespace contains fundamental classes and base classes that define commonly-used value and reference data types, events and event handlers, interfaces, attributes, and processing exceptions. § The System.Collection namespace contains classes that define lists, queues, arrays, hashtables and dictionaries. § The System.Web.UI.Control is the parent of all Web Form Controls. Three commonly used controls belong to this namespace—Page, UserControl and LiteralControl. Every ASP.NET page is compiled to the Page control by the ASP.NET page framework. § The System.Web.UI.WebControl namespace contains classes that define the ASP.NET server controls.
  • 17. § The System.Web.UI.HTMLControlsnamespace contains classes that define HTML controls. § Namespaces like System.Data, System.Data.OleDb, System.Data. SqlClient, System.XML are classes that deal with manipulating database, XML and other data. I will look at these namespaces in Chapter 3. I will be discussing these namespaces at various places in the book. In this chapter, I will be discussing the System.Web.UI.WebControl namespace and the System.Web.UI.HTMLControls namespace. Note "Imports" is a Visual Basic construct. If you are using C#, you will substitute "Using" for "Imports". If you have included Web Controls in your .aspx form and want to refer to them in your Code Behind file your import construct will look like the following: Imports System Imports System.Collections Imports System.Web.UI Imports System.Web.UI.WebControls You then define a class. All your functions and subs go in this class. A Visual Basic Code Behind file might look like this: Imports System.Data Public Class BaseClass Inherits System.Web.UI.Page Sub somesub() End Sub Function somefunction() End Function End Class Note that I have introduced the Inherits keyword here. The difference between the Inherits and Imports keyword is that the Imports statement only brings in the definition of a set of functionality, but does not actually make use of it. It is comparable to including a reference in Visual Basic. The Inherits keyword is more dynamic. An object that inherits certain functionality can also override and/or extend the parent functionality. This form becomes a base class and one that your aspx page will inherit from. Inheritance is quite simple. You just have to put a statement at the top of the aspx form: <%@Page Language="VB" Inherits="BaseClass" Src="nameofCodeBehind.vb" %> Let's take a look at an example. We will take the Events.aspx file and split it into two files: events_cb.aspx and events_cb.vb, the Code Behind file. events_cb.aspx <%@Page Language="VB" Inherits="BaseClass" Src="events_cb.vb" %> <html> <body style="background-color='beige'; font-family='verdana'; font -size='10pt'"> <form method="POST" runat="server">
  • 18. Qty:<asp:TextBox id="Qty" Runat="server"/> Price: <asp:TextBox id="Price" Runat="server"/> Amount:<asp:TextBox id="Amount" ReadOnly = "true" Runat="server"/> <asp:Button id="btnCalculate" Text="Calculate" OnClick="Calculate" Runat="server"/><br> </form> </body> </html> Events_cb.vb Imports System Imports System.Collections Imports System.Web.UI Imports System.Web.UI.WebControls Public Class BaseClass Inherits System.Web.UI.Page 'Each control used on events.aspx to be declared here with same id Protected qty as textbox Protected price as textbox Protected amount as textbox Sub Page_Load(Source As Object, E As EventArgs) 'this is the page load event 'gets fired each time the page is loaded response.write("Page Load Event : -->fired <br>") if NOT (isPostBack) 'the code here gets fired only one at page load 'subsequent reloads do not fire it due to the not isPostBack construct
  • 19. response.write("The not isPostBack construct:--> ensures this does not get fired at reloads") end if End Sub 'This sub moved from the events.aspx form Sub Calculate(src As Object,e As EventArgs) Amount.Text = Cstr(cint(qty.text)*cint(price.text)) End Sub End Class Let's discuss the example in detail: 1. I have defined a class called BaseClass in the Code Behind file and moved the Calculate sub from the aspx form into this class. This class inherits from the System.Web.UI.Page. 2. I will be extracting the text value of textboxes Qty and Price, multi- plying the two, and putting the result in the Amount textbox. Since I need to access the property values of these three textboxes from my Code Behind file, I declare three textboxes with the same id in the Code Behind file like this: 3. Protected qty as textbox 4. Protected price as textbox Protected amount as textbox 5. The Qty, Price, and Amount textboxes are WebControls since I have initialized them with the asp: tag prefix. For example, the Qty textbox is created as follows: <asp:TextBox id="Qty" Runat="server"/> Controls exist in the System.Web.UI.WebControls namespace hence I must import this namespace before I can access their properties by code. This is done by the import directive at the top of the page: Imports System.Web.UI.WebControls 6. Finally, I have coded the Page_Load Event to display a message when it gets fired. This event gets fired each time the page gets loaded. At times we need to code events that get fired only at the initial page load and not on subsequent reloads. For example, we can bind a Web Control to a data source (I will be discussing data binding in Chapter 4) and want the binding to occur only once at page load. The isPostBack property of the page lets us determine if posting has already occurred to the page. Thus we use the following construct to display a message only on the first load of the page: IF NOT (isPostBack) response.write("The not isPostBack construct:—>……") End If
  • 20. Server Controls There have been many attempts to encapsulate HTML rendering into controls. We have had objects like VBXs, OLE controls, and ActiveX controls, all of which attempted to give us a simple way to generate HTML. The problem with these controls is that they made the presumption that the users accessing our sites would have the very latest browsers. The server side controls introduced with ASP.NET make no such requirement of the browser. They render pure HTML to the browser, thus overcoming the shortcoming of its client side brethren. These server controls are fully encapsulated objects that expose events, properties, and methods to programmatic access. They exist independent of the web form on which they are drawn. ASP.NET provides two sets of controls: HTML and Web Controls. HTML controls correspond to traditional HTML controls with the same name. Web Controls provide features such as automatic browser detection, a consistent object model, and data binding capabilities. HTML Controls HTML controls belong to the System.Web.UI.HTMLControls namespace and derive from the HTMLControl base class. They are initiated with the runat = "server" attribute. For example, the following HTML creates an instance of a HTMLInputText named textbox 1. <Input type = "text" runat="server" id = "textbox1" value ="test"> These controls map directly to their HTML counterparts and are useful for providing backward compatibility with ASP. These controls do not provide any abstraction like their Web Control counterpart and do not automatically detect the requesting browser to modify the HTML they render. The main use of these controls is to provide a quick migration path to ASP.NET as existing HTML tags can be upgraded to server controls just by supplying the runat = "server" attribute. I have provided examples of various HTML controls in the following example with a detailed discussion of each one afterwards. Figure 2.2 shows various HTML controls. Figure 2.2: HTML Controls. htmlControls.aspx
  • 21. Random documents with unrelated content Scribd suggests to you:
  • 22. Merrimeg, looking up, could see the bare spot in the sky directly overhead, where the lost star belonged. “Where are you taking us?” said Pennie. “I’m taking you to the gnomes’ house,” said Merrimeg. “We’ll soon be there. It’s two gnomes who’ve been very good to me; I know where they live. They’re the ones to help us.” “Is one of them named Malkin?” said Florrie. “And the other one Nibby?” said Pennie. “Yes,” said Merrimeg.
  • 23. “LOOK!” SHE CRIED “Then it’s no use,” said Pennie. “We’ve been there already.” “They were asleep,” said Florrie, “and we woke them up, and they didn’t like it a bit. They wouldn’t get up for any foolish old star,— that’s what they said. But they told us about you, and that’s how we came to hunt you up. But the horrid gnomes wouldn’t do a thing for us; they wouldn’t even get up.”
  • 24. “They’re not horrid,” said Merrimeg. “Oh dear, I don’t know what we’re going to do now.” She looked down sadly into the dark water of the pool, trying to think what to do next. She gave a little jump of surprise, and looked harder. Far, far down, away down deep under the water of the pool, —— She saw a star. “Look!” she cried, and pointed her finger at it. The starlight fairies leaned over, and looked down into the pool. “That’s it!” cried Florrie. “It’s my star!” cried Winnie. “It’s our lost star!” cried Pennie. “Dropped down from the sky to the bottom of this pool.” “Then,” said Merrimeg, “you’d better go down and get it.” “Oh no! oh no! oh no!” cried the three fairies together. “We mustn’t get our wings wet!” said Pennie. “We’d never be able to fly home if our wings got wet,” said Winnie. “But you have no wings,” said Florrie to Merrimeg. “No, she has no wings,” said Pennie. “She shall go down for our star,” said Winnie. “You will, won’t you?” “The water’s deep and dark,” said Merrimeg. “But you have no wings,” said Florrie. “The water’s cold and gloomy,” said Merrimeg. “But you have no wings,” said Pennie. “I wonder if I could do it,” said Merrimeg. “Oh please!” cried Winnie. “Oh dearest Merrimeg, please get my star.”
  • 25. “I’ll see how deep it is,” said Merrimeg, and she threw a stone into the middle of the pool. The water rippled away as the stone sank, and the star could not be seen any longer. “Oh!” cried Winnie. “Now you’ve sent my star away! It’s gone!” But the water became quiet in a moment, and there was the star again, shining bright at the bottom of the pool. At that instant, they heard a splash in the water, and a shrill voice, like the voice of an angry boy, cried out: “Who breaks my glass? Who breaks my glass?” “What can that be?” whispered Merrimeg. “I don’t know,” said Florrie. “Throw another stone, and perhaps we’ll hear it again.” Merrimeg tossed another stone into the pool, and when the ripples had died away they heard the same voice again. This time it said: “Who strikes my children? Who strikes my children?” “Throw another,” whispered Pennie, and Merrimeg cast in another stone. This time there was a loud wail, and the voice cried: “My children! My children! I’m coming! I’m coming!” Then there was a splash, and nothing more. They waited a long time, but they heard nothing more. “I’m going to see,” said Merrimeg. “I may have hurt somebody. I can see better from the end of that log.” There was a dead log, the trunk of a fallen tree, lying out from the bank of the pool into the water, and Merrimeg stepped onto it and getting down on her hands and knees crawled out to the end of it. It was slippery, and she had to hold on very carefully to keep from falling off into the water.
  • 26. She leaned over as far as she could and looked down into the pool. She looked everywhere for the star, but she couldn’t see it; there seemed to be some dark thing under the water between herself and the star. “The star is gone!” she said to the others, in a whisper. As she said this, a hand came up out of the water and seized her wrist and pulled her off the log. Over she went into the pool, down, down, far down. The hand never once let go of her wrist. It pulled her down and down, faster and faster. At first she thought she was going to choke with the water, but in a moment she was all right again, only wet, very wet. And in another moment she was at the bottom, and the hand let go of her wrist. She stood up on her two feet on a floor of what looked like glass. There was a pale light shining all about her through the water, and she saw that it came from the star, lying on the floor nearby. Just over her head was a roof of glass, and it was badly broken in three or four places. Around her were walls of glass. She was in a little house of glass, with a broken roof, and full of water. A hand took hold suddenly of her arm, and she was dragged across the floor in a great hurry, by the creature who had pulled her down from the log. It was a sprite; a water sprite, whose head just reached to her shoulder; full-grown, evidently, in spite of being so small; with pointed ears, and no hair on his head, and long green water grass trailing around him. He dragged Merrimeg straight to the star, and picked it up by a kind of sling that it was meant to hang by. It flashed and glittered as he snatched it up. He pointed to the floor, and Merrimeg saw, lying there side by side, three tiny sprites, babies, no bigger than kittens, and exactly like the grown one who was holding her arm. They looked as if they were asleep, but on the forehead of each one was a black and blue bruise, and Merrimeg knew that she must have hurt them with her stones, as well as broken the glass of their little home.
  • 27. Their father, if it was their father, motioned to her to pick them up. She gathered them up in her arms, and the sprite, carrying the star in one hand, seized her hair with the other hand and sprang up towards the holes in the broken glass roof; and in another instant she was being dragged upward through the water as fast as she had been pulled down. UPWARD THROUGH THE WATER ... She almost dropped the little mites she was holding in her arms, but she hugged them tighter, and when they came to the surface of the pool she was holding them safe in her arms. They came out dripping on the bank of the pool, and there were the three starlight fairies.
  • 28. “Oh!” cried Winnie. “She’s brought my star!” The water sprite dragged Merrimeg onto the dry grass, and took the three babies from her arms and laid them down on the grass. “Now! now! now!” he cried. It was plain that he was very angry. He was trembling all over. “What are you going to do about it? Look what you’ve done.” “Why,” said Merrimeg, “why——” “First comes this horrible star and breaks in the roof of my house and lets in all the water! And then—oh you wicked creatures!—you throw down your ’bom’nable stones and break my roof all to pieces and kill my children—my poor children—look at ’em—look at ’em, will you?—look at those bumps on their foreheads—oh my poor children —You ’bom’nable creatures, you! You perfectly awful wicked ’bom’nable——” “Oh!” said Florrie. “It’s too bad. I’m so sorry.” “We didn’t mean to do any harm,” said Pennie. “And after he was so kind as to bring our star back to us, too,” said Winnie. “Is this your star?” cried out the water sprite. “Yes, yes! It’s mine!” said Winnie. “Then you’ll never get it! You shan’t have it!” cried the water sprite, angrier than ever. “You’ll see what I’m going to do with it! You’ll never get it again! Ah! there she goes!” He swung the star by the sling in his hand, and gave it a great fling, and away it flew over the tree tops, in a beautiful bright curve, higher and higher, and then lower and lower. But he was greatly mistaken if he thought he could get rid of the star in any such way as that. Quick as a flash all three of the starlight fairies were in the air, and off like three arrows over the tree
  • 29. tops after the star. Before Merrimeg knew what was happening they were out of sight, and the star was gone. The water sprite was so astonished that he forgot he was angry. “Who are they?” he said, in a kind of whisper. “They’re the starlight fairies,” said Merrimeg. “They hang out the stars each night, and to-night they dropped that star by accident, and it fell into your pool. If they don’t get it back they can’t go home.” “But they killed my children and——” At that moment the lost star appeared over the tree tops, coming on towards them in a streak of white light, and in another moment the three starlight fairies stood on the ground, and Winnie was swinging the star in her hand. “Oh! oh!” she said, and began to laugh and cry at the same time. She couldn’t say another word, for joy. “We’ve got it!” cried Florrie. “We can go home now!” “But what about these poor babies?” said Merrimeg. “Can’t we do anything for them?” The three fairies knelt around the three tiny bodies on the ground, and looked closely at their foreheads. “Why,” said Pennie, “it’s nothing but a bruise!” “So it is,” said Winnie and Florrie together. “Is that all?” said Merrimeg. “Is that all?” said the water sprite, looking very helpless and pitiful. “Yaa! yaa!” came a little piping cry from the grass, and the water sprite dropped to the ground beside the babies. “He’s crying!” sang out the water sprite. “His eyes are open!” Another little cry and another came from the grass, and the water sprite sang out again:
  • 30. “They’re all crying! They’re all coming to! They’re all right! Hurrah!” He picked up the three babies and bundled them in his arms, and without another word gave a leap into the water and splash! went down and out of sight, babies and all. Florrie laughed, Winnie laughed, and Pennie and Merrimeg laughed too. “But I’m sorry his house is ruined,” said Merrimeg. “Oh, he’ll mend it in no time,” said Florrie. “But see, Merrimeg, you’re all wet!” “Goodness!” said Merrimeg. “I’d forgotten all about it.” “Stand here,” said Florrie, and she and the other two fairies placed Merrimeg in the middle and turned their backs to her. Their wings began to flutter gently, and then began to move faster and faster, making a strong breeze which blew all over Merrimeg. Fanned in this way by the great butterfly wings, she was soon dry. “Good-by, Merrimeg,” said Florrie. “Good-by, dear Merrimeg,” said each of the others. “Thank you for my star,” said Winnie. “You must think of us whenever you look up at the stars.” “Indeed I will,” said Merrimeg.
  • 31. The starlight fairies stood on tiptoe for a moment, and fluttered their wings; and then they rose quietly in the air, and flew straight up. When they were above the tree tops, they began to circle round and round, going higher and higher; far, far up through the night they went on circling; and long after Merrimeg could see them no more, she could see the star, bright as a diamond, go circling up and up.... She ran away home, and crept in quietly at the front door, and lay down in her bed and snuggled under the covers. Her mother was still asleep. She must have gone to sleep herself presently; she woke up and thought of the lost star, and remembered that she had not waited to see if it was in its place. She got out of bed and tiptoed to the window, and putting her head out looked up. A star was sparkling just overhead, where there had been none before. The star was in its place. “I’m glad of that,” she said out loud. “What did you say?” said her mother, waking up. “I was only saying—only saying——” “Never mind what you were saying. Go back to bed, and go to sleep. You’ll catch your death of cold.” “Yes, mother,” said Merrimeg.
  • 32. “N MERRIMEG AND THE ECHO DWARFS MERRIMEG AND THE ECHO DWARFS OW, Merrimeg,” said Merrimeg’s mother, “take this basket and go to the brook in the woods, and bring me back a basketful of water cress for supper. And be sure to come straight back.” “Yes, mother,” said Merrimeg. And she went off down the village street singing, with her basket on her arm. But first she put in her pocket the blue saltcellar from the kitchen, full of salt. She walked a long way into the woods, and at last she came to a little brook running along over the stones. There in the clear water she found plenty of fresh green water cress growing. She pulled it up by the handful and filled her basket with it. She knew that she ought to go straight home, but this was not one of her days for being good. She left the basket on the grass, and
  • 33. took out of her pocket the saltcellar with the salt in it. Then she looked around for birds. A blue bird came hopping by on the ground, and Merrimeg stole up behind it on tiptoe, and sprinkled a little salt right down over its tail. But just at that minute the bird flew up into a tree, and Merrimeg was too late. Off went the bird from tree to tree, and Merrimeg ran after it as fast as she could, holding out her saltcellar. Pretty soon the bird hopped down onto the ground again, and Merrimeg tiptoed up behind it and sprinkled her salt down over its tail. But she was just a bit too late, and the bird flew up into a tree. Merrimeg followed the bird a long, long way, and whenever it hopped down onto the ground she tried to sprinkle a little salt on its tail; but she was always just a wee bit too late. At last, when she was at the foot of a hill that rose up out of the woods, she stamped her foot and cried out: “Oh, you good-for-nothing naughty bird!” “Naughty bird!” came back her own voice to her from the top of the hill. Merrimeg was astonished. She had never heard an echo before. She thought she would try it again, so she called out: “Oh, you naughty bird, come down here!” Her own voice came back to her from the same place up the hill, but it didn’t quite repeat her words; it said: “Come on down!” The echo must have made a mistake. Merrimeg was more than ever astonished. She waited a minute, and then the same voice came down to her from the top of the hill, and it said: “Down here!”
  • 34. The echo had got it right this time. Evidently it must have been a very young echo indeed. Merrimeg forgot all about the blue bird, and she began to climb the hill to find out who it was that was mocking her. She didn’t know it, but there was an Echo Dwarf who lived in a cave near the top of the hill, and there lived with him his little boy, a very little boy, who was just learning how to make echoes. Big Hark was the father’s name. Little Hark was the little boy’s name. Big Hark had a great deal of trouble in teaching Little Hark to make echoes, for Little Hark often forgot, and instead of calling back the same words he had heard, he would often call back words of his own. Besides, if the words he had to call back were big words, he always got them mixed up. His father never knew when he was going to make a mess of everything. And when he did that, it made Big Hark so angry he could hardly speak. Merrimeg went on up the hill, and pretty soon she called out again: “Why couldn’t I catch the bird with my salt?” “Too slow!” came back the voice from the top of the hill. Merrimeg couldn’t understand this at all. She listened for a minute, and then she heard another voice up above her:
  • 35. “OXTRAGOB BORGS, GOOBLIK!” “My salt! Oxtragob borgs, gooblik!” This was Little Hark’s father, and when he said “Oxtragob borgs, gooblik!” he meant, in the private language of the Echo Dwarfs, “Wrong again, stupid!” Big Hark and Little Hark were standing in front of their cave, and Big Hark was letting Little Hark practice at making echoes, as Merrimeg
  • 36. came up the hill. Not many people came that way, and Big Hark was glad of the chance to give his little boy a lesson. Merrimeg came on further and further up the hill, and after a while she stopped and called out again: “Are you still there?” “Still there!” came back the voice. This made her quite angry. She did not like to be mocked every time she opened her mouth. She cried out: “Stop mocking me!” “Mocking me!” came back the voice. This made her very angry indeed. Without saying anything more she clambered on up the hill and stopped all out of breath on a little ledge before the mouth of a cave. There a little further on along the path was standing Little Hark himself, with his hands up to his mouth, all ready to shout back an echo. His father had gone inside the cave. Little Hark was very small indeed, and Merrimeg looked quite like a giant beside him. She ran to him and stood over him and shook her finger at him and said: “What do you mean by mocking me all the time?” “All the time?” said Little Hark, looking very much frightened. “Yes, all the time!” said Merrimeg. “What do you mean by it?” “Mean by it?” said the little Echo Dwarf. “Don’t you dare repeat everything I say to you!” cried Merrimeg. “You naughty thing, you’re mocking me!” “You’re mocking me!” said Little Hark, beginning to cry.
  • 37. “HOW DARE YOU SAY SUCH A THING? HOW DARE YOU?” “Why, you awful little thing, I’m not!” cried Merrimeg. “How dare you say such a thing? How dare you?” “How dare you?” said Little Hark, crying harder. This made Merrimeg very angry, so angry that she could not say another word. She seized hold of Little Hark’s arm and shook him.
  • 38. There she was shaking him, pretty hard too, and Little Hark was bawling out loud, when Big Hark, his father, came out of the cave and hurried towards them to see what was the matter. Big Hark was very strong, though he was not very big. He threw his arms around Merrimeg and dragged her away from Little Hark and hauled her along to the cave and pulled her into it. Before she knew it her arms were bound up tight with tough vines which Big Hark had snatched down from the wall. Big Hark made her sit down on the floor with her back against the wall, and he and Little Hark stood before her. Little Hark looked at his father and said: “Kormsdee lokspit calliper?” This meant, in the private language of the Echo Dwarfs, “What are you going to do with her?” “Lokspit meegs,” said Big Hark, “doomdog askbiddle beddagog diskorfunjax krissmuss.” This meant, “I am going to keep her here for seven Christmases, for you to practice your echo lessons on.” “Snexterbean?” asked Little Hark. This meant, “What then?” “Lokspit snexter,” said Big Hark, “flambilly noformikin beskeem.” This meant, as you may imagine, “I am then going to give her to the Fire Bubbles at the back of the cave.” Merrimeg tried to get her arms loose, and cried out: “I want to go home! I want to go home!” Big Hark nudged Little Hark, reminding him to practice his echo, and Little Hark said: “Go home!” “All right, then, I will!” cried Merrimeg, and she struggled to her feet and started to run towards the mouth of the cave. But Big Hark caught her and held her, and she cried out:
  • 39. “Let me go! Let me go!” “Go!” said Little Hark, echoing her words, and Merrimeg cried: “I can’t! He won’t let me!” Now Little Hark should have said “Let me!” But he forgot all about echoing her words, and he shouted out two words of his own. “Run back!” he cried, and this was what gave Merrimeg her chance to escape. For Big Hark was so angry at Little Hark’s forgetting to echo back Merrimeg’s own words, and calling back words of his own instead, which was strictly forbidden, that he let go of Merrimeg and turned round on Little Hark and shook his finger at him and shouted, “Let me! Oxtragob borgs, gooblik!” and boxed Little Hark’s ears with all his might and main. Little Hark broke out crying, and Merrimeg dashed away into the dark at the back of the cave, and ran on faster and faster into the darkness. Pretty soon she heard Big Hark shout out something in his own language, and she knew that he was running after her. So she
  • 40. ran on faster than before, and in a moment she struck against a wall in the dark, and feeling it with her hands she turned a corner and saw something which almost made her stop breathing. It was a stream of sparkling red fire, running across the ground right in her path. As she looked at it, an enormous bubble, like a soap bubble, but red-hot and shining like fire, rose from the stream and floated up in the air towards her. She crouched down, and the Fire Bubble floated up to the ceiling and burst with a loud crack and a shower of sparks; and then another one rose from the stream and floated towards her and broke against the ceiling; and then another and another, one right after the other. Merrimeg was frightened so that she couldn’t move. She didn’t dare to go on, and she didn’t dare to go back. She heard the voice of Big Hark behind her in the dark, crying out: “Sdig! sdig!” And at that moment she—— Well, she heard another voice, from the other side of the Fire Bubbles, and it said: “I believe it is, brother, I believe it is.” Merrimeg clapped her hands with joy and cried: “Here I am! Help me! Help me!” Big Hark’s voice behind her echoed her words, “Help me!” and the other voice, on the far side of the Fire Bubbles, said: “I suppose we’d better help her, brother Nibby.” “I’m quite of your opinion, brother, quite,” said the voice of brother Nibby. “Quite,” said Big Hark, in echo, just behind Merrimeg. As he said this he threw his arms around her and began to drag her back into the cave. Little Hark came running up, and he tugged at his father’s coat and said, “Skeems non doogdag, himpotter,” which meant, “Please don’t hurt her, father.”
  • 41. But he hadn’t any more than said these words than Malkin and Nibby, the two gnomes, rushed across the stream of fire, knocking the Fire Bubbles right and left with their hands, and Malkin picked up Little Hark, slung him on his shoulder, and ran back with him across the stream of fire, knocking the Fire Bubbles right and left as he ran. “Ishkameerz! O ishkameerz!” cried Big Hark, and he let go of Merrimeg and rushed down to the stream of fire, holding out his hands towards the little boy on the other side. But he did not dare go near the fire. “I believe now maybe he’ll give her up,” said Malkin from the other side of the fire. “Give her up!” said Little Hark, struggling on Malkin’s shoulder. “Fee skimble fen bitkin, fee skimble fen moklin!” shouted Big Hark, which meant, “If you’ll give up the boy, I’ll give up the maiden!” “Good!” cried Malkin. “Good!” said Little Hark. Nibby the gnome ran to Merrimeg and unfastened the vines that bound her arms, and lifted her up and carried her across the stream of fire, knocking the Fire Bubbles away with his hand, so that she wasn’t harmed in the least; and at the same time brother Malkin crossed the stream of fire and put down Little Hark beside his father. “Hurry! hurry!” cried Merrimeg, and pulled the two gnomes away into the darkness beyond the fire. “Farewell!” cried Malkin. “Good-by!” called back Little Hark, and his father shook him by the shoulder and said, “Oxtragob borgs, gooblik!” which meant, as you know, “Wrong again, stupid!” “Take me home quick,” said Merrimeg as she went on between the two gnomes deeper and deeper into the darkness. “She’s not very polite to-day, brother,” said Malkin.
  • 42. “Not very, brother, not very, indeed,” said Nibby. “She really ought to say ‘Please,’ I think.” “Maybe something’s happened to bother her,” said Malkin. “Maybe so, maybe so,” said Nibby. “I wonder what it could be.” They went down into the earth for a long way, and then they went up under the earth for a long way, and at last they stopped. “Here we are, brother Nibby,” said Malkin, and he appeared to be opening a door. “Home again, brother Malkin,” said Nibby, and the three of them climbed a ladder, and Nibby raised a door overhead, and the next minute they were in the gnomes’ kitchen. Malkin and Nibby sat themselves down at their little table, where a candle was burning, and Malkin said: “I suppose we’d better ask her to stay to supper, brother.” “Just what I was thinking,” said Nibby. “But which one of us will ask her?” “Oh, you must be the one to do that, brother.” “Oh, no, you can do it so much better, brother Malkin. You must——” “Goodness gracious me!” said Merrimeg. “You don’t need to ask me. I can’t stay anyway.” “Not very polite to-day, brother, not very polite,” said Malkin. “I’m afraid not, brother, I’m afraid not,” said Nibby. “Oh, I’m so sorry,” said Merrimeg. “Please excuse me. I really have to go home. And I’m ever so much obliged to you.” She climbed the ladder to the ceiling and went up through the little door there, and calling down good-by she stepped out onto the roof of the gnomes’ house, and closed down the door after her. She ran as fast as she could through the woods, until she came to the brook where she had left her basket. There it was, full of water
  • 43. Welcome to our website – the ideal destination for book lovers and knowledge seekers. With a mission to inspire endlessly, we offer a vast collection of books, ranging from classic literary works to specialized publications, self-development books, and children's literature. Each book is a new journey of discovery, expanding knowledge and enriching the soul of the reade Our website is not just a platform for buying books, but a bridge connecting readers to the timeless values of culture and wisdom. With an elegant, user-friendly interface and an intelligent search system, we are committed to providing a quick and convenient shopping experience. Additionally, our special promotions and home delivery services ensure that you save time and fully enjoy the joy of reading. Let us accompany you on the journey of exploring knowledge and personal growth! ebookultra.com