Tải bản đầy đủ (.pdf) (50 trang)

Tài liệu Programming Microsoft SQL Server 2000 with Microsoft Visual Basic .Net - P8 docx

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (1.48 MB, 50 trang )


A typical ASP.NET applicat ion will be run in an environm ent in which m any
browsers ar e connect ed t o a single Web server or a farm of Web servers. For
sim plicit y, I discuss the case of t he single Web server, but t he sam e general
principles apply t o a farm of Web servers. Th e asynch ronous nat ure of
com m unicat ion between a Web server and browsers facilit ates the m aint enance
of a large num ber of concurrent browser sessions with a single Web server. Each
of t hese browsers can have a differ ent session st ate wit h t he Web server. I n
ot her words, t he sam e page can show different cont ent s t o differ ent users
depending on t he int eract ions of each user wit h the Web server. At t he same
tim e, a dat abase server can pr ovide a consist ent set of inform at ion across
m ult iple browser sessions.
Anot her defining char act er ist ic of Web applicat ions is t hat a Web server can serve
pages t o m any different kinds of browsers. Alt hough all brow ser t ypes render
HTML code in pages served from a Web server, the rendering isn’t necessarily
invariant fr om one browser t ype t o t he next . Som e brow sers handle client -side
script ing in one language but not anot her. Different browser versions target
different HTML versions ( 3.2 and 4.0 are two com m on HTML versions). Som e
support absolut e posit ioning, but support isn’t universal for t his feat ure. For
differences such as t hose not ed, it ’s not uncom m on for Web applicat ions to have
to “sniff” t he brow ser t ype to det erm ine it s charact erist ics and then send a page
that is rendered and behav es well on t hat browser.
ASP.NET offers a couple of approaches t o handling Web application developm ent
issues. First , ASP.NET can elicit HTML from Web serv ers in an at t em pt t o
m inim ize t he im pact of different browser t ypes on t he way t hat a page appears in
a browser. Second, ASP.NET has built - in capabilit ies for detecting browser t ypes
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
and t heir capabilit ies. Your applicat ions can tap t hese capabilit ies to dir ect
browsers t o pages t hat are rendered well wit hin t hem.
N ot e
I t’s a big drain on limit ed Web application developm ent


resources to det ect browsers and prepare m ultiple pages that
are rendered well in different browsers. As a business
em ploying talented Web developers, wouldn’t you rather
those developers spend t heir tim e cr eating m ore useful
content in different pages than creating m ultiple copies of a
sm aller number of less useful pages so as to optim ize for
different browser s? Because ASP.NET is free wit h the II S 5.0
Web server, and t he Internet Explorer browser is free with
m ost Microsoft product s and from Microsoft ’s I nt ernet site, I
recom mend you use the Internet Explorer browser for your
ASP.NET applications. Note t hat Micr osoft didn’t encourage
m e t o m ake this st atem ent. I nst ead, I m ak e the st atem ent
on t he basis of m y observations about how taxing it is on
organizations to cr eat e Web solut ions t hat work well with
m ult iple browsers.
Pages and t he Pa ge Cla ss
As indicat ed in Chapt er 8, ASP.NET builds on ASP. For exam ple, Web servers can
discern an ASP.NET page based on it s ext ension, .aspx. The extension for an
ASP.NET page is the sam e as t he ext ension of ASP pages w it h an x appended t o
it. For exam ple, an ASP.NET page will have a nam e like m ypage.aspx.
Any ASP.NET solut ion can have m ult iple pages wit hin it . You can designate one
page as t he st art page for an applicat ion. (There is no st art up obj ect as there is
wit h Windows applicat ions. ) An ASP.NET solut ion can contain m ultiple pages, and
users can navigate wit hin and bet ween t he pages of a solut ion. I n addit ion, you
can navigat e t o old .asp page files or even ot her types of files, such as .ht m or
.ht m l files.
When an ASP.NET applicat ion opens an .aspx file, t he applicat ion launch es t he
Page_Load event procedure ( unless you rem ove it) . The Page class is a
program m ing abst ract ion of an .aspx file. This Page class provides m any valuable
services. For exam ple, you can use a page’s I sPost Back property t o det erm ine

whether a page is being displayed for t he first tim e in a session or is the result of
a browser post ing a page back t o a Web server. A page’s Session propert y
enables your application to m anage variables across m ult iple asy nchronous
connect ions t o a Web server fr om a browser wit hin a session. A page’s
Applicat ion propert y point s t o an Applicat ion object for sharing variable values
acr oss an applicat ion’s users. One of the m ost excit ing feat ur es of t he Page class
is t he way t hat it autom ates t he m anagem ent of form at t ing and cont ent bet w een
round-t rips; I ’ll discuss t his t opic m ore fully in t he “Session St ate Managem ent ”
sect ion. Wit h t he Response and Request properties for a page, you can explicit ly
m anage the exchange of inform at ion bet ween a Web server and a brow ser. The
Response property enables you t o echo cont ent t o Web pages so t hat you can
m onit or t he ingoing and out going v alues for controls and variable values on Web
pages. Developers w ill r ecognize t his capabilit y as particularly handy for
debugging.
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
My personal favorite feature of ASP.NET is t he way t hat it separat es page layout
issues from pr ogram logic. Those of you fam iliar wit h ASP w ill recall how you had
the opportunit y (indeed it was a r equirem ent) t o m ix HTML layout w it h your script
for m anaging t he logic on a page. Alt hough you can st ill do t his, Visual St udio
support s a t w o- file st ruct ur e for t he Web page class. The file with t he .aspx
ext ension cont ains t he HTML layout code. A new, second, file cont ains the
program logic. This file’s extension depends on the program m ing language. For
exam ple, if your Web page file has t he nam e yourpage.aspx, it s code file in Visual
Basic w ill hav e t he nam e yourpage.asp x.vb. The page w it h t he .asp x ext ension
cont ains controls, such as labels, t ext boxes, and list boxes. The code file (w it h
the aspx.vb extension) includes page init ializat ion code, event procedures for t he
obj ect s on t he page, and other rout ines and declarat ions t o m anage t he behavior
of a page.
An ASP.NET applicat ion t hat y ou develop w it h Visual St udio has t w o folders for
m anaging a solut ion. Your .aspx and .aspx.vb files reside in a folder on t he Web

server. The proj ect folder ’s default locat ion is in t he wwwroot subdirect ory of the
I net pub folder of t he I I S serv er host ing your applicat ion. You can have m ult iple
files wit hin t he Web folder for a solut ion, including ot her Web pages and graphic
files. You open a Web solut ion by invok ing any .aspx file wit hin t he folder on t he
Web server . A second folder in your Visual St udio solut ion direct ory cont ains t he
solut ion file ( .sln) for an ASP.NET pr oj ect . This second folder is the sam e one
Visu al St udio uses t o st ore the files for your Window s applicat ion solut ions. Use
the .sln file t o open your solut ion in Visual St udio when you w ant t o edit t he
design of a solut ion. Bot h the Web folder and t he regular Windows folder can
have the sam e nam e t o facilit ate t heir coordination.
Cont rols on Pa ges
You st art an ASP.NET proj ect in Visual Studio .NET by click ing New Pr oj ect on t he
Visu al St udio .NET St art Page and t hen highlight ing t he ASP.NET Web Applicat ion
tem plat e. Designat e a folder nam e for your new proj ect . Th e default locat ion is on
the localhost I I S server. See t he over view of ASP.NET in Chapt er 8 for t he three
elem ent s t hat you need t o creat e ASP.NET solut ions. As Visual St udio .NET st arts
the proj ect , it creat es a Web sit e for the solut ion on t he Web serv er.
When t he proj ect opens, y ou w ill view an em pt y Web page ( w it h t he .aspx
ext ension) . The default nam e for t he page is WebForm 1.aspx. You can assign a
new nam e t hat is m ore m eaningful in t erm s of your applicat ion by right-clicking
the file’s nam e in Solut ion Explorer and choosing Renam e to assign a new nam e.
Use t he Toolbox t o add cont rols t o a blank page. You can display t he Toolbox by
choosing Toolbox from t he View m enu from wit hin Design v iew for t he st art up
page. There are t hr ee cat egories of nat ive controls that you ar e likely t o add t o
an .asp x page. These reside in t hree separat e t abs wit hin t he Toolbox.
• First , you can click t he HTML tab in t he Toolbox t o expose classic HTML
cont rols. These controls can operate as HTML elem ent s or as a new t ype of
HTML server cont rol. I f you are used t o building Web solut ions w it h ASP or
som e other Web developm ent language ( such as Perl) , you probably
already have a work ing knowledge of HTML cont rols. One key dist inct ion

bet w een classic HTML form cont rols and HTML server controls is t hat
server cont rols offer an obj ect m odel for program m ing on a Web server.
• Second, you can click the Web Form s t ab in t he Toolbox t o ex pose Web
server form controls designed explicitly for use wit h ASP.NET. These
cont rols are r endered as HTML on Web pages, but t hey have properties,
m et hods, and event s associat ed w it h them . You can use Web server
cont rols on t he ASP.NET Page class inst ances sim ilarly to t he w ay you use
Windows form controls on form s in Windows applicat ions.
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
• Third, y ou can use t he item s on t he Dat a t ab in t he Toolbox t o invoke
wizards for declaring and inst ant iating ADO.NET obj ect s, such as a data
adapt er for SQL Server or a dat a set. These ADO.NET obj ect s reside on a
page at design t im e, and t hey can t hus sim plify your code by reducing the
need t o declare and inst ant iate object s. See Chapt er 1 for the discussion
of an exam ple t hat dem onst rat es t he use of t hese form s in a Windows
applicat ion. This ch apt er cont ains supplem ent ary ASP.NET applicat ions
that illust rat e t he use of Dat a cont rols on Web pages.
HTML cont rols and Web serv er controls bot h represent t ext boxes, but t ons, and
sim ilar kinds of cont rols. The list of HTML control it em s m aps t o t he classic HTML
form cont r ols, such as a label, a t ext field, a subm it but t on, and a reset but t on.
HTML cont rols can run eit her as classic HTML form cont rols or as HTML server
cont rols. You need to designat e a special attribute (runat= "server" ) in order for
the it em s on t he Toolbox’s HTML tab t o be available for pr ogram m ing on a Web
server. HTML cont rols w it h the special at t ribut e set t ing are oft en designat ed HTML
server cont rols in t he ASP.NET docu m ent at ion. You m ust give HTML ser ver
cont rols a nam e at design tim e by assigning a value t o their I D at t ribute in order
to reference t hem program m atically on a Web ser ver. Wit hout t he special runat
at t ribut e set t ing, HTML controls pass t heir values along in eit her of t he t w o
tradit ional ways: in t he HTTP header or in t he body of a form on an .aspx Web
page. I f you use t he special attribut e set t ing, you can m anipulat e HTML cont rol

propert ies sim ilarly t o t he way you m anage cont rols on a Window s form .
N ot e
The HTML form ’s m ethod at tribute t ells a Web server where
to look for values wit h a form on a Web page. The “get ”
sett ing for a m et hod att r ibute says t o look in the HTTP
header. This is a query st ring appearing after the URL t o
which a Web page navigates. The “post ” set ting designat es
the storage of values in t he body of a Web page.
Web server cont rols convey HTML to browsers. However, t he HTML syntax for
these cont rols doesn’t m ap in a one- t o- one way to HTML form cont rols. For
exam ple, t he RadioBut t onList Web server cont rol cont ains t ext inside an HTML
table elem ent . This cont rol doesn’t m ap t o t he HTML Radio But t on control,
alt hough bot h cont r ols can hav e a sim ilar look on a Web page. Select ed Web
server cont rols include But t on, Label, List Box , Dat aGrid, HyperLink, and about 25
m ore. You can see t he full list of Web server cont r ols wit h links for dr illing down
further int o t he properties, m et hods, and ev ent s for each one in t he “Web Server
Controls” t opic of t he Visual St udio .NET docum ent at ion.
N ot e
You can open the Visual St udio .NET docum ent ation fr om the
Program s m enu on the Window s St art butt on. Choose
Microsoft Visual St udio .NET Docum entat ion from t he
Microsoft Visual St udio .NET it em on t he Program s m enu.
Use t he Search t ab to ret urn a list of item s m at ching a
search crit erion, su ch as Web Server Controls. I f you have
difficulty finding a particular topic because too m any it em s
ret urn, sort by Tit le by click ing t he Tit le header in the Search
results window. Then scroll through the item s, which are now
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
list ed in alphabetical order, to the it em you want.
Web server cont rols and HTML server cont rols share select ed feat ur es in

com m on. For exam ple, one killer feat ure is t he abilit y for form cont rols to
m aint ain t heir values on round-trips to a Web server. This m aint enance of form
field values can require a lot of program m ing w ith tradit ional HTML cont rols on
HTML forms. However, Web server cont rols and HTML server cont rols provide t his
feat ure w it hout any program m ing. Anot her significant feat ure shared by Web
server cont rols and HTML server cont rols is t he abilit y t o use t he validat ion
cont rols t o assess t he content of cont rols on a form . Validat ion cont r ols enable
certain validit y t est s, su ch as whether t he cont r ol cont ains an ent ry, whet her t he
cont rol has a value in a specified form at , and whet her t he value is in a specified
range. Again, no program m ing is necessary for base funct ionalit y. How ever,
lear ning a few program ming trick s for t he validat ion cont rols can enable you t o
refine t he user experience.
I st rongly urge y ou t o use Web ser ver controls inst ead of HTML server cont rols in
all your ASP.NET applications. As t heir nam es im ply, Web server cont r ols run
aut om at ically on t he Web server. There is no special at t ribut e for you to set in
order t o use t he cont r ols on a Web server. Web serv er cont rols are m uch m ore
ext ensive in their variet y than HTML server cont rols. I n addition t o t he st andard
HTML cont rol t ypes, Web serv er cont rols offer a variet y of specialized cont rols to
facilitat e y our display and m anipulat ion of data, including a Dat aGrid cont rol for
displaying dat a as a table. Dev elopers who build solut ions for ent ering or showing
dat es are likely to find t he Web server Calendar cont rol of special value. This
cont rol enables entering and displaying dates on a st andard m ont hly calendar
display. The general HTML form at for a Web server control appears her e. The asp
prefix denotes t he cont r ol as a Web server cont rol. The cont rolnam e param et er
specifies the t ype of cont rol (for exam ple, label) . The attribut es param eter
corresponds to a list of property set t ings.
<asp:controlname attributes runat="server">

ASP.N ET D esign I nt erface s
I have been developing Web solut ions pr im arily with Micr osoft t echnology since

approx im at ely 1995, and the ASP.NET design int erface is by far m y favorit e over
that t im e span. This is because t he ASP.NET design interface offers you the
flexibilit y of dev eloping a Web applicat ion very m uch as you cr eat e Windows
solut ions wit h Visual Basic .NET. I t leaves m e fr ee t o focus on m y solution inst ead
of being dist ract ed by Web layout dev elopm ent issues. I n ot her w ords, ASP.NET
provides a design environm ent t hat m akes m e feel as t hough I ’m cr eat ing a
typical Window s solut ion— except it ’s for the Web. (See Chapt er 8 for m or e
coverage on t his point.) Nonet heless, the ASP.NET design env ir onm ent st ill has
som e unique feat ur es, which will be covered in this sect ion.
Aft er init ially cr eat ing a new ASP.NET proj ect ( as descr ibed in t he preceding
sect ion) , you are confronted w it h t he HTML Designer, which displays a blank Web
layout page. By default , this page will hav e t he filenam e WebFor m 1.aspx. The
first point to not e is t hat t he t ab for t he page has two cont rols at it s bot t om . The
page opens w it h the Design cont rol select ed (unless you ch ange t he default
set t ing) , which pr esent s a graphical view of t he page. Click ing the HTML cont r ol
displays t he HTML code behind t he page. I n ot her words, t he HTML Designer
offers two views for each page— a Design view for graphical dev elopm ent of a
page and an HTML code view for program m at ic design of a page.
When y ou look at t he page in HTML view, you’ll see t hat it st arts w it h an @Page
direct ive. I n t his direct ive are set t ing assignm ent s that you should t ypically not
edit . Next t here is a docu m ent declarat ion declaring t he page to be an HTML 4.0
docum ent.
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Aft er t he t w o prelim inary declarat ion st at em ent s, the HTML code w indow displays
an ht m l t ag. A m at ching / ht m l t ag ends t he docum ent . Ot her HTML tags nest
bet w een t hese beginning and ending t ags for the HTML cont ent w it hin a
docum ent. Tw o set s of m at ching t ags nest direct ly beneat h t he ht m l and / ht m l
tags. The cont ent bet ween the head and / head t ags is m ostly boilerplate m at erial
rout inely prepared by Visual St udio for all .aspx page files t hat it generates.
Howev er, t he t it le and / title t ags cont ain t he title t hat appears in t he t itle bar of a

Web browser window w hen t he brow ser display s the page. You can edit a page’s
title eit her from t he HTML code window or t he Propert ies window for t he
docum ent. Changes in either locat ion updat e t he other locat ion autom at ically.
The next pair of nest ed t ags wit hin t he ht m l and / ht m l t ags are t he body and
/ body t ags. Unless you change t he default sett ings, t he body t ag will have an
MS_POSI TI ONI NG at t ribut e set t ing of GridLayout . This handy set t ing let s you
drag and dr op cont rols around a Web page just as on a Windows form . The
MS_POSI TI ONI NG at t ribut e set t ing corresponds to t he pageLayout pr operty
set t ing in t he Propert ies window for t he docum ent . The default set t ing for t he
pageLay out set t ing m at ches t he MS_ POSI TI ONI NG at t ribut e set t ing of
GridLayout . Choosing the ot her property set t ing of FlowLayout for t he pageLayout
property rem oves t he MS_POSI TI ONI NG at t ribute from t he HTML code window.
This alternat iv e layout set t ing allows y ou to posit ion cont rols on a Web page as
you do cont ent on a t ypical word processing docum ent. Th is is the t radit ional
HTML way of posit ioning cont rols on a page, and it provides your great est
com patibilit y with br owser t ypes— especially older browser t y pes t hat don’t
support absolut e posit ioning. How ever, y ou give up t he convenience of being able
to drag and drop cont rols on a Web page. The form and / form tags reside w it hin
the body t ags. All the cont rols on a Web page appear wit hin t he form and / form
tags. I will discuss these t ags next as I r eview t he page design for our
WebApplicat ion1 proj ect , w hich was init ially discussed in Chapt er 8.
N ot e
The WebApplicat ion1 sam ple, like m ost of the sam ples in t his
chapt er, exist s as t wo folders. Both folders hav e t he nam e
WebApplication1. One contains just two files in its root . One
of these files is WebApplication1.sln. The folder cont aining
this file belongs in t he direct ory that your com puter uses for
st oring Visual Basic .NET Windows solut ions. You can open
the WebApplicat ion1 solut ion in Visual St udio by choosing
Open Solution from the File m enu and select ing

WebApplication1.sln. You m ay need to browse t o the folder
containing WebApplication1.sln befor e being able to select it .
The second folder contains WebFor m1.aspx in it s root . This
folder belongs in t he wwwroot direct ory of the Inet pub folder
on t he com puter from which you will be r unning t he
applicat ion. You can open the Web page by browsing
ht t p: / / < webserver> / WebApplicat ion1/ WebForm 1.aspx.
Recall t hat t he WebApplicat ion1 proj ect from Chapter 8 cont ains t wo cont r ols: a
button and a label. Click ing t he but t on causes t he label t o show “Hello World.”
Figure 11-2 reveals t he but t on cont r ol above t he label cont rol in Design view for
WebApplicat ion1’s WebFor m 1.aspx file. Bot h cont rols are Web server cont rols. I
select ed t hem fr om t he Web For m s t ab of t he Toolbox. When y ou add a cont r ol
from t he Toolbox t o a Web page, you can select it in the Toolbox and t hen size
the cont rol by dragging it out on your Web page. Alt ernat iv ely, you can right -click
the cont rol t ype in t he Toolbox and choose Copy. Then right - click in Design v iew
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
for the Web page, and choose Paste. This adds the control wit h pr econfigur ed size
set t ings in t he upper left corner of t he page. I f your docum ent has a Gr idLayout
set t ing for its pageLayout pr operty, you can t hen j ust drag t he cont rol to it s
desired locat ion. Figure 11-2 shows t he label and but t on cont r ols w it h t heir
preconfigured size sett ings.
Figur e 1 1 - 2 . The ASP.N ET D e sign vie w for W e bFor m 1 .a spx in t he
W e bApplicat ion 1 proj e ct .

Figure 11-2 sh ows sev eral t oolbars. All t he cont rols on t he bot t om row, after t he
first t w o, belong t o t he Layout t oolbar. I f t his t oolbar isn’t visible, y ou can m ake it
appear in t he usual way for Windows applications— right - click any t oolbar, and
select t he one y ou want (Layout ) from t he cont ext m enu. ( You can also select
Toolbars from t he View m enu and select t he appropriat e toolbar from t he list .)
The cont r ols on t his t oolbar can m ake fast work of t ypical form layout design

task s, such as aligning, sizing, and sp acing cont rols. Not ice also in t he figur e t hat
the Web page appears wit h a gr id. The default set t ing is for cont rols to snap t o
the grid m arks as you m ov e controls around t he form . I f you prefer m ore
granular positioning or you don’t w ant t o show a gr id, you can achieve t hese
result s by choosing Options from t he Tools m enu. I n t he Options dialog box ,
Open t he HTML Designer folder and select Disp lay. The right port ion of t he dialog
box then reveals cont rols for set t ing the Snap To Grid and Show Grid opt ions.
This portion of the Opt ions dialog box also includes t ext boxes for you to specify
the spacing bet w een grid m ark s in Design v iew. You can also cont rol t he
appearance of t he grid by right - click ing any blank area of a page in Design view
and ch oosing Pr opert ies. I f t he pageLay out property for a page is GridLayout , t he
General t ab of t he DOCUMENT Propert y Pages dialog box exposes t he Show Gr id
check box. Clearing t he check box st ops the grid fr om appearing, but cont rols still
snap t o t he grid when you m ove t hem .
I f you sw it ch from Design v iew t o HTML view, you can see t he form and / form
tags inside bounding body and / body t ags. Just as t he form and / form t ags are
wit hin body and / body t ags, so are t he tags for t he but t on and label controls
wit hin t he t ags for t he form . You can see from t he follow ing HTML excerpt for t he
WebForm 1.aspx page t hat the button and label cont r ols are Web server cont rols
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
because t heir init ial t ag begins with t he asp prefix (asp : Button and asp: Label) .
Aft er t he t ag designat ion init iat ing a cont r ol, a series of at t r ibut e set t ings defines
the cont rol feat ures. The attribut e set t ings are so num erous that t hey cause the
cont rol tag to wrap t o a second line. The id at t r ibut e indicat es t he nam e by w hich
your pr ogram can refer t o t he cont rol. The TOP at t ribut e designat es how far
down, in pixels, a cont rol is from t he t op page border. Not ice that t he label
cont rol is 40 pixels farther dow n t he page t han t he but t on. The but t on control is 7
pixels closer t o the page’s left border t han t he label cont r ol.
<body MS_POSITIONING="GridLayout">
<form id="Form1” method="post” runat="server">

<asp:Button id="Button1” style="Z-INDEX: 101; LEFT: 8px;
POSITION: absolute; TOP: 8px” runat="server” Text="Button">
</asp:Button>
<asp:Label id="Label1” style="Z-INDEX: 102; LEFT: 15px;
POSITION: absolute; TOP: 48px” runat="server">Label
</asp:Label>
</form>
</body>

Right - click ing any blank area in the Design v iew t hat appears in Figure 11- 2
opens a cont ext m enu from which you can choose View Code. This exposes the
Visu al Basic code behind t he form . (See Fig ure 11- 3.) The t ab disp laying t he code
behind t he form has t he nam e WebFor m 1.aspx.vb. This is also t he nam e of t he
file cont aining t he code behind t he form . The Solution Explor er window t o the
right of t he code window sh ows t he WebForm 1.aspx.vb file select ed. You won’t
see t his f ile unless you’ve select ed Show All Files on the Solut ion Explorer t oolbar .
The declarat ions at t he top of t he m odule w indow indicat e t hat t he code resides in
a class inst ance nam ed WebFor m 1, which inherit s pro-perties, m et hods, and
event s from the Page nam espace in the Syst em .Web.UI hierarchy. I n addition,
the But t on1 and Label1 cont r ols on t he Web page are inst ances of t he But t on and
Label classes. The definit ions for t he But t on and Label classes reside in t he
Syst em .Web.UI .WebCont rols nam espace.
N ot e
Recall that y ou can discover the funct ion of controls on a
toolbar, such as the Show All Files control, by hovering your
cursor over t he control until a descriptive phrase appears.
Figur e 1 1 - 3 . The code w indow for th e W ebApplica tion s1 sam ple w it h t h e
W e bForm 1 .aspx.vb file sele ct e d in Solution Ex plorer.
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.


When y ou choose to view t he code for an em pt y Web page, you w ill see j ust one
procedur e, t he Page_Load event procedure. This procedur e will cont ain a
com m ent t hat reads, “Put user code t o init ialize t he page here.” I ret ained t his
com m ent in Figure 11- 3 for y our r eference. The Page_Load ev ent procedure
works m uch like t he For m_Load ev ent procedure for Windows applicat ions. You
can m ak e assignm ent s that need t o t ak e place before a user interacts wit h a Web
page. I n t he WebApplication1 sam ple, t he Page_Load ev ent pr ocedure assigns
“Click m e” t o t he Text property for But t on1 and clears t he Text propert y for
Label1. The But t on1_Click event procedur e can be included because of t he
Prot ect ed Wit hEvent s declaration at t he t op of t he m odule.


Creat ing and Running ASP.N ET Solu t ions
Building Web solut ions w it h ASP.NET can be very st raight forward for Visual Basic
dev elopers. This section includes several sam ples t o illust rat e basic Web design
issues. You st art wit h a review of t echniques for com piling and v iewing Web
pages. Th is review leads to a sam ple t hat drills down on t echniques for m anaging
the appearance of cont rols on a Web page. I n t he process, you learn synt ax
issues for t he Page_Load ev ent procedur e as well as event procedur es for
cont rols on a Web page. Anot her pair of sam ples dem onst rat es how t o const ruct
a m ult ifunct ion calculat or. These samples illust rate t ech niques for working w it h
text boxes on a Web page as well as how t o opt im ize pages for different t ypes of
browsers. The sect ion concludes wit h a sam ple t hat aut om at ically det ect s the
type of t he browser request ing a page and t ransfers cont rol t o a page opt im ized
for that brow ser t ype.
Com piling a nd View ing W eb Pa ge s
I f you inst all t he folder w it h t he WebFor m 1.aspx file for WebApplicat ion1 in t he
wwwroot folder for t he Web serv er on your local com puter, you can open t he
solut ion in a browser wit h t he following URL:
ht t p: / / localhost / WebApplicat ion1/ WebFor m 1.aspx

Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
This URL designates t he local Web server by specifying localhost . I f you have t he
WebApplicat ion1 folder cont aining WebForm 1.aspx inst alled on a differ ent
com put er running I I S and t he .NET Fram ew ork, you can open t he Web page in a
browser wit h t he following URL. Serv ernam e typically specifies t he nam e of the
com put er running t he Web server.
ht t p: / / < server nam e> / WebApplicat ion1/ WebForm 1.aspx
I recom m end running pages from a browser. I n fact , if you are sure t hat your
applicat ion will have t o be r un by users wit h different browser t ypes, you should
test your Web pages w it h as many of t hese browser types as possible. You m ight
even consider t rying out your Web pages wit h different sett ings. Som e set t ings
can affect how t he page w orks in a browser— part icular ly if the page t aps any
client -side (t his m eans browser) funct ionality. I w ill cover exam ples of t hese
issues later in t his ch apt er.
You m ust com pile any changes to a page before you can v iew t hose changes in a
browser. Therefore, for init ial t est ing purposes, you m ight care t o open your Web
pages from wit hin Visual Studio so y ou can m ore easily debug y our solutions. You
can right - click a page t hat you want t o open in Solut ion Explorer and choose one
of t w o m enu it em s to view t he page. I f you haven’t m ade any changes t o t he
page since t he last build, you can select View I n Br owser. This opens a Browse
window w it hin Visual Studio t hat simulat es t he appearance of the page as if it
were in a browser. I f you edit ed t he page’s layout or code behind t he page since
the last t im e t he page was viewed, choose Build And Brow se from t he cont ext
m enu when you right -click t he page in Solut ion Explorer. Th is recompiles t he
solut ion w it h any ch anges that y ou m ade before disp laying t he page wit hin t he
Visu al St udio Br owse window . No m at t er which approach you use to open a
Browse window, t he window appears on a separate t ab like t he ones for t he Web
page’s layout and t he code behind the page. Right -click wit hin t he Browse window
for a select ion of com m on br owser com m ands, such as Back, Forward, and
Refresh Browser.

Figure 11-4 sh ows WebForm 1.aspx fr om WebAp plicat ion1 w hen it init ially opens
in I nt er net Explor er and aft er a click of the but t on labeled Click Me. One click of
the but t on causes a label below t he but t on t o show Hello World. Repeat edly
clicking t he but t on seem s t o hav e no effect , alt hough the Page_ Load and
But t on1_Click event procedur es operat e for each click . This is because each click
ret ur ns t he Web page back t o t he server for processing. The reason not hing
appears t o change is t hat the label’s Text pr operty get s set t o t he sam e value on
each ret urn t o t he server as a result of a click of But t on1.
Figu r e 1 1 - 4 . The t op w in dow sh ow s how W e bForm 1 .aspx from
W e bApplicat ion 1 a ppears w hen it in it ia lly loa ds. Th e bottom w in dow
show s t he W eb page aft er a click of t h e bu tt on .
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.

Rem em ber in g t he St at e of a Pa ge
One w ay t o im pr ove on the operat ion of t he page in WebApplicat ion1 is to keep
track of whet her a browser opens a page for t he first t im e or whet her a brow ser
sends a page back t o t he server t hat is already open w it hin t hat br owser. You can
addit ionally coordinat e t his know ledge with t he appearance of t he page. This will
give users fresh inform at ion t hat reflect s t he stat e of t he page— not j ust t he sam e
inform at ion on ev ery click .
The Post backSam ple proj ect has a Web page nam ed WebForm 1.aspx t hat reflect s
four separat e st ates. Furt herm ore, alt hough the page address, WebForm 1.aspx in
the Post back Sam ple folder, st ays the sam e, t he appearance of t he page’s form
changes wit h each successive click . The page’s appearance indicat es t he st ate of
the form on t he page. When t here are no m ore st at es t o show, t he page m ak es
all but t ons inv isible so that a user cannot repeat edly click a but t on wit hout
anyt hing happening.
N ot e
Like the WebApplicat ion1 sam ple, t he Post back Sam ple exist s
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.

as two separat e folders. Place the folder that contains
WebForm 1.aspx in the wwwroot direct ory of the Inetpub
folder for the computer serving as a Web server. Place the
folder wit h Post backSam ple.sln in the dir ect ory st oring your
Visual Studio proj ect s.
Figure 11-5 sh ows how the WebForm 1.aspx page appears for each su ccessive
st at e. The top window shows t he page when a user init ially navigat es t o t he page.
This init ial st ate for t he Post back Sam ple applicat ion has t he sam e appearance as
the init ial page for the WebApplicat ion1 solution. After a user clicks t he but t on
labeled Click Me, t he page r et urns saying, “Hello Wor ld” , but the page ch anges it s
look in ot her ways as well. Specifically, t he Postback Sam ple applicat ion m akes
But t on1 invisible. I n addit ion, t he applicat ion show s a new button, Bu t t on2, w it h
a Text pr opert y of “Hello Show ed” . By click ing this second but t on, the user causes
the Web page t o t ravel t o the serv er and back t o the browser . While at the Web
server, t he layout of the page changes again. This t im e, t he button w it h a label of
Hello Show ed changes it s label t o “ Click for advice”. I n addit ion, Label1 appears
wit h a new Text propert y of “Get busy .” Clicking t he button one m ore t im e
changes t he appearance t o t he window at t he bottom of Fig ure 11- 5. I n t his final
st at e, no but t ons are visible for a user t o click . I n addit ion, t he code behind the
page has no m ore dist inct appearances left t o present . I n addit ion t o m aking bot h
buttons invisible, t he Text property for Label1 changes t o “Stay busy.”
Figur e 1 1 - 5 . A sin gle W eb page , W ebFor m 1 .aspx in t h e Post back Sam ple
pr oject , prese nt s fou r different app eara n ces dependin g on th e st ate of
t he W eb page a n d t he con t r ols on it.
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.

Figure 11-6 sh ows t he Design view of WebForm 1.aspx in t he Post backSam ple
proj ect . Not ice t hat it cont ains t wo buttons and a label ( Label1). I dragged t he
size of But t on2 so that it is slight ly wider t han But t on1. I f you ev er program m ed
wit h ASP, y ou’ll appreciat e how rem arkable t he sim plicit y of the page is. Not ice

specifically t hat no code is m ixed in w it h t he page.
Figu r e 1 1 - 6 . The D esign view of th e W e b page t h at appear s in t he four
diffe r ent st at e s show n in Figure 1 1 - 5 .
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.

Because t he layout for t he Web page is so basic, t he cont rol of the page’s
appearance m ust be in t he logic of the code behind t he page. Before focusing on
the specific code behind t he page, I want t o int roduce t he I sPost back pr opert y for
a page. This property t ells the server whet her t he page is loading init ially or as
the result of t he user clicking a cont rol on t he page t hat sends t he page back t o
the server. I f t he I sPost back property is False, the page is opening init ially . I f t he
I sPost back propert y is True, t he page is being sent back t o t he server by t he user
clicking on a cont rol. The logic of t he Post backSam ple applicat ion t akes
advant age of t he I sPost back property t o help cont r ol t he appearance of the Web
page.
The follow ing list ing sh ows the t hree ev ent pr ocedures m anaging t he appearance
of WebForm 1.asp x in t he Post backSam ple proj ect . The list ing comm ences w it h
the Page_Load ev ent pr ocedure. This procedur e fires each t im e t he page opens—
whet her init ially or ot herwise. However, w it hin t he Page_Load event , different
code execut es depending on t he value of the I sPost back propert y and t he Text
property set t ing for But t on2. I f t he I sPost back property is False, the procedure
m akes three property assignm ents t hat m ake t he page appear like t he top
window in Figure 11-5. The ElseI f and Else clauses for t he I f st atem ent handle
cases in w hich t he Web page ret urns to t he serv er aft er opening init ially. The
ElseI f clause specifically handles t he case in which a page returns to the server
wit h t he Bu t t on2 Text propert y equal t o “Hello Showed”. I f t he page ret urns t o
the server wit h a differ ent value for t he But t on2 Tex t property, t he I f st at em ent
rout es control t o t he Else clause.
The Button1_Click ev ent fires when the user clicks But t on1. Th ere is only one
chance t o do this because the Click ev ent pr ocedure m akes t he but t on invisible.

I n addit ion, t he procedure assigns “Hello Wor ld” and “Hello Showed” as values t o
the Text property for Label1 and But t on2, respect ively.
The Button2_Click ev ent procedure can fire in eit her of t wo circum st ances, and it
needs t o respond differ ent ly t o each case. Therefore, it uses an I f…Then…ElseI f
st at em ent t o cont r ol w hich stat em ent t o execut e. When Label1 sh ows “Get
busy.”, t he procedure changes the Text propert y for But t on2 t o “Click for adv ice”.
I f t he label show s “St ay busy.”, t he ElseI f clause operates to m ak e Butt on2
invisible.
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
’If it is a first-time presentation, then
’set like WebApplication1, or
’if it is a postback with Hello Showed button,
’then change message to Get busy, or else
’change message to Stay busy.
If IsPostBack = False Then
Button1.Text = “Click me"
Button2.Visible = False
Label1.Text = “"
ElseIf IsPostBack = True And _
Button2.Text = “Hello Showed” Then
Label1.Text = “Get busy."
Else
Label1.Text = “Stay busy."
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
End If
End Sub


Private Sub Button1_Click(ByVal sender As System.Object, _

ByVal e As System.EventArgs) Handles Button1.Click

’Make label say Hello World.
Label1.Text = “Hello World"

’Make Text for Button2 read Hello Showed and
’make Button2 visible.
Button2.Text = “Hello Showed"
Button2.Visible = True

’Make Button1 invisible.
Button1.Visible = False

End Sub


Private Sub Button2_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button2.Click
’If Label1 says Get busy, show Button2
’with a Text property of Click for advice,
’else make Button2 invisible.
If Label1.Text = “Get busy.” Then
Button2.Text = “Click for advice"
ElseIf Label1.Text = “Stay busy.” Then
Button2.Visible = False
End If

End Sub

A Mu lt ifunct ion Ca lcula tor W eb Pa ge

One of the t ruly cool feat ur es of form s on pages in ASP.NET is t hat t he property
values for cont r ols persist bet ween r ound- t r ips t o t he servers. The preceding
sam ple didn’t highlight t his feat ur e because the whole point of t hat sam ple was t o
show how to change t he values of cont r ols on successive round- t r ips to the
server. This sam ple, the WebCalculat or pr oj ect , takes advant age of aut om atic
persist ence of cont rol property v alues during t he round- t r ip from a br owser t o a
Web server and back again. I f you did m uch ASP coding, you m ay recall that it
was necessary t o writ e code if you w ant ed cont rols to display t he sam e values on
the way back from a server as on t he w ay up to a server.
The WebCalcu lat or proj ect highlights t he aut om at ic persist ence of cont rol values
by let t ing users ent er values in t w o t ext boxes. When t he user click s one of four
buttons for a t ype of ar it hm et ic bet w een t he v alues appearing in t he t ex t box es,
the page goes off t o t he serv er. The procedures for perform ing t he arit hmetic
work direct ly w it h t he Text property for t he text box cont rols on t he Web page. I n
ot her words, t he values pass t o the server v ia t he text box cont rols. Wit h
tradit ional HTML form s, t he values pass to t he server as nam e and value pairs.
The nam e represent s the cont rol nam e, and t he value represents t he entry in t he
cont rol. I f values need t o appear in a page when it ret ur ns to a browser from a
server on a t raditional HTML form , you m ust w rite code to r eassign the values t o
cont rols on t he page t he server sends back t o t he browser.
The WebCalcu lat or proj ect is a four-funct ion calculat or. Each funct ion has it s ow n
button wit h a Text property setting representing t he type of calculat ion it
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
perform s— nam ely, + , - , * , and / . Users ent er values in t he first t wo t ex t box es
on the Web page. Users access this proj ect by navigat ing t o WebCalculat or.aspx
in t he WebCalculator project . When I first cr eat ed t he proj ect , ASP. NET assigned
WebForm 1.aspx as t he st at page nam e for t he proj ect . However, I revised the
nam e to WebCalcu lator.aspx in Solution Explorer using t he t echnique described
previously. When t he page goes t o t he server, it perform s the calculat ion denot ed
by t he button a user clicks. A sim ple event procedure for each button handles

this. Each of t he event procedur es for t he four but t ons calls another procedure
that form ats the value ret urned t o t he browser in t he t hird t ext box on t he page.
This form at t ing procedure assigns a color to t he text box For eColor property
based on t he value r et urned and m akes t he font bold.
Figure 11-7 sh ows t he WebCalculat or pr oj ect working for a pair of values in t he
first and second t ext boxes. The t op w indow shows the WebCalculat or.aspx page
before a user click s one of the four funct ion but t ons. Not ice t hat t he user ent er ed
values in t he first and second t ext box es (-2.2 and 3.3). The t hird t ext box is
em pt y. The bot t om window sh ows the page t hat ret urns from t he Web serv er
aft er the user click ed the bot t om but t on on t he form wit h a Text proper t y equal t o
/ . I n t he bottom window, t he applicat ion populat es t he t hird t ext box wit h t he
quot ient of -2.2 divided by 3.3. The t ext box displays the result to single-
precision accu racy. Because t he value is negat ive, it appears in r ed wit hin t he
browser window. I n addit ion, t he value in t he t hird t ext box appears in a bold
font.
Figu r e 1 1 - 7 . Th e W ebCalcu la t or .asp x page before and aft er a t rip t o t h e
W e b se rve r. Th e u se r in voked t he r ou nd-trip to t he se rve r by clicking t h e
bot tom butt on ( / ) .
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.

The buttons on t he page have I D propert y set t ings of But t on1 t hrough Button4
from t he t op but t on t o t he bot t om but t on. The cor e of t he applicat ion is the event
procedur es behind each of t hese but t ons. Th e m odule for t he page st arts by
declaring a single-precision variable nam ed sgn1. Th is var iable st ores t he result
of t he calculat ion perform ed on t he cont ent s of Text Box1 and Text Box2. Because
the m odule declares sgn1 as a Single dat a t ype and its input v alues are converted
from a St ring dat a t ype to a Single dat a t ype, t he result of t he arithm et ic
com put ation has a single data t ype. However, t he Text propert y of Text Box3
requires a String dat a t ype. Therefore, t he assignm ent of sgn1 t o a Text property
invokes t he ToSt ring m et hod t o convert a num eric value t o a st ring.

Each of t he Click ev ent procedures for t he buttons invok es the
ColorTex t I nText Box3 pr ocedure. Th is procedur e has an I f st atem ent w it h Then,
ElseI f, and Else clauses. The I f st at em ent assigns one of t hree colors t o TextBox3
based on t he value in sgn1. Positive values result in a For eColor pr opert y
assignm ent for Text Box3 of green. Negative values lead t o a red For eColor
property assignm ent . I f t he sgn1 value is 0, t he procedur e assigns black as the
foreground color for TextBox3. No m atter w hat color t he procedure assigns t o t he
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
ForeColor property for Text Box3, t he procedure concludes by m aking the font
bold.
Dim sgn1 As Single
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click

’Add text boxes.
sgn1 = CSng(TextBox1.Text) + CSng(TextBox2.Text)
TextBox3.Text = sgn1.ToString
ColorTextInTextBox3()

End Sub


Private Sub Button2_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button2.Click

’Subtract text boxes.
sgn1 = CSng(TextBox1.Text) - CSng(TextBox2.Text)
TextBox3.Text = sgn1.ToString
ColorTextInTextBox3()


End Sub


Private Sub Button3_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button3.Click

’Multiply text boxes.
sgn1 = CSng(TextBox1.Text) * CSng(TextBox2.Text)
TextBox3.Text = sgn1.ToString
ColorTextInTextBox3()

End Sub


Private Sub Button4_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button4.Click

’Divide text boxes.
sgn1 = CSng(TextBox1.Text) / CSng(TextBox2.Text)
TextBox3.Text = sgn1.ToString
ColorTextInTextBox3()

End Sub


Sub ColorTextInTextBox3()

’Assign forecolor to TextBox3 based on result value.
If sgn1 > 0 Then
TextBox3.ForeColor = Drawing.Color.Green

ElseIf sgn1 < 0 Then
TextBox3.ForeColor = Drawing.Color.Red
Else
TextBox3.ForeColor = Drawing.Color.Black
End If

’Make font bold to highlight assignment.
TextBox3.Font.Bold = True

Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
End Sub

A Mu lt ifunct ion Ca lcula tor in a Table
All t he sam ples in t his chapt er t o t his point display Web pages in a Microsoft
I nternet Explorer browser. I t est ed t he pages with t he I nt er net Explorer 5 and
I nternet Explorer 6 browsers. Howev er, m any visit ors browse I nt ernet sit es wit h
non–I nternet Explorer browsers. I am t he Webm ast er at
www.Program m ingMSAccess.com , a sit e t hat cat ers t o t he int erest s of Micr osoft
Access, Micr osoft SQL Server, and Visual Basic developers. This sit e ex plicit ly
target s the int erest s of t hose loyal to Micr osoft product s, and it has done t his for
about four years as I writ e t his chapter. Nevertheless, about 15 percent of t he
visit ors t o the site browse pages wit h a Netscape browser. The overwhelm ing
m aj ority of t he Net scape browser sessions are conduct ed with a Netscape 4.x
browser.
As st at ed previously, I fully believe in su pport ing one browser. My personal
preference is for t he m ost recent version of t he I nt er net Explorer browser
because it provides the lat est feat ures from a proven soft w are leader— Microsoft .
When dev eloping intranet and extranet solut ions, you can m andat e a single
browser for t he solut ion. When developing I nt er net solut ions, t he guidelines for
deciding which browser (or how m any browsers) t o support can be m or e com plex

because you cannot m andat e t hat users browse your sit e w it h a specific brow ser.
Therefore, for I nt er net solut ions, you have at least a couple of opt ions. First, you
can prom inent ly st at e in browser- neutral t ext t hat a page is opt im ized for one
browser. I f users want t o v iew t he page, t hey can inst all the browser for w hich
the page is optim ized. Second, you can develop different pages for different
browsers. This sect ion illust rat es t he second approach w it h t he sam ple from t he
preceding sect ion.
I n deciding w het her t o prepare m ult iple versions of a page for different browser
types, t he first st ep is to view t he page in all the t arget browsers that y ou plan t o
support . For exam ple, Fig ur e 11-8 shows t he WebCalculat or.aspx page in a
Net scape 4.01 browser. Not ice t hat the page doesn’t look like t he w indows in
Figure 11-7. The prim ar y reason for t he divergence in appearance is that t he
Net scape browser doesn’t support absolut e posit ioning. ASP.NET uses t his feat ur e
to enable t he posit ioning of controls on a Web page w it h drag-and- dr op
techniques.
Figu r e 1 1 - 8 . Th e W e bCalcu la t or .asp x pag e in a N e t scape 4 .0 1 brow ser.
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.

Many tradit ional Web developers have experience using t ables to posit ion cont rols
on a Web page. When you posit ion cont rols by placing t hem inside t able cells, you
don’t need t o rely on absolut e posit ioning control pr opert y set t ings to designat e
the locat ion of a cont r ol on a form . By using a t able inst ead of absolut e posit ion
cont rol set t ings, you can dev elop a page t hat is m uch m ore likely t o appear
sim ilar in bot h I nt ernet Explorer and Net scape browsers. Th e t rick t o achiev ing
sim ilar result s in different browsers by posit ioning cont rols in t ables is to set t he
pageLay out property to FlowLay out . Recall t hat this set t ing causes cont ent t o
appear on a Web page in t he flow pat t ern of a word processor inst ead of t he
classic Visu al Basic drag-and- drop st yle.
I built anot her version of t he WebCalculat or .aspx page in t he WebCalculat or
proj ect to dem onst rat e the st eps for creat ing a calculat or in a table. St art by

creat ing a new Web page in t he WebCalculat or proj ect . Choose Proj ect , Add Web
Form from t he Visu al St udio m ain m enu in Design view. I n t he Add New I tem
dialog, choose the Web Form tem plat e, nam e t he new Web page
WebCalcu lat orI nTable.aspx, and click Open. I f you are using t he sam e proj ect
and y ou want t o duplicate m y st eps, nam e t he new Web page som ething else, for
exam ple, My WebCalcu latorI nTable.asp x. Set t he pageLayout property for the
docum ent t o FlowLay out ( as descr ibed in t he “ASP.NET Design I nt er faces”
sect ion) .
Add a t able w it h four colum ns and t hree rows t o t he WebCalculat orI nTable.aspx
Web page. Start by choosing I nsert and t hen Table from t he Table m enu. Set t he
Colum ns box t o 4 and click OK on t he I nsert Table dialog box, leaving t he default
set t ing of 3 for the Row s box . Next em bed a new t able in t he second colum n of
the original t able’s third row. The em bedded t able should have one colum n of four
rows wit h a widt h of 27 pix els. After posit ioning the cursor w here you w ant t he
em bedded table, choose Table, I nsert, Table. Set the Rows box to 4 and t he
Colum ns box t o 1. Assign 27 t o t he Widt h box. Then click OK.
Next copy t he t ext box and but t on cont r ols from the WebCalculat or.aspx page t o
the WebCalcu latorI nTable.aspx page. You can also copy t he label wit h a Text
property of “Web Calculat or” . Arrange t he layout so t hat it looks like Fig ur e 11-9.
I achiev ed t his look wit h a sequence of copy - and- past e operations from t he
WebCalcu lat or.aspx page t o t he WebCalculat orI nTable.asp x page. No ot her
operations were necessary.
N ot e
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.

×