asp.net handson 02smiertsc/2336itec/asp.net_handson_02.pdfuse a text editor? notepad – bare bones?...
TRANSCRIPT
![Page 1: ASP.NET HandsOn 02smiertsc/2336itec/ASP.NET_HandsOn_02.pdfUse a Text Editor? Notepad – bare bones? Notepad – not really feasible with server-side development in ASP.Net Visual](https://reader030.vdocument.in/reader030/viewer/2022041103/5f02c5fc7e708231d405f0e2/html5/thumbnails/1.jpg)
ASP.NET Hands-OnLesson 02
By Susan L. Miertschin
![Page 2: ASP.NET HandsOn 02smiertsc/2336itec/ASP.NET_HandsOn_02.pdfUse a Text Editor? Notepad – bare bones? Notepad – not really feasible with server-side development in ASP.Net Visual](https://reader030.vdocument.in/reader030/viewer/2022041103/5f02c5fc7e708231d405f0e2/html5/thumbnails/2.jpg)
CHANGE IS GOOD?Our Development Environment Changes Now
![Page 3: ASP.NET HandsOn 02smiertsc/2336itec/ASP.NET_HandsOn_02.pdfUse a Text Editor? Notepad – bare bones? Notepad – not really feasible with server-side development in ASP.Net Visual](https://reader030.vdocument.in/reader030/viewer/2022041103/5f02c5fc7e708231d405f0e2/html5/thumbnails/3.jpg)
Use a Text Editor?
Notepad – bare bones? Notepad – not really feasible with server-
side development in ASP.Net Visual Studio and its text editor – much
better – essential, really
![Page 4: ASP.NET HandsOn 02smiertsc/2336itec/ASP.NET_HandsOn_02.pdfUse a Text Editor? Notepad – bare bones? Notepad – not really feasible with server-side development in ASP.Net Visual](https://reader030.vdocument.in/reader030/viewer/2022041103/5f02c5fc7e708231d405f0e2/html5/thumbnails/4.jpg)
Getting Started with Visual Studio – Our Development Environment Changes!
Open Visual StudioFile – New Project
![Page 5: ASP.NET HandsOn 02smiertsc/2336itec/ASP.NET_HandsOn_02.pdfUse a Text Editor? Notepad – bare bones? Notepad – not really feasible with server-side development in ASP.Net Visual](https://reader030.vdocument.in/reader030/viewer/2022041103/5f02c5fc7e708231d405f0e2/html5/thumbnails/5.jpg)
Getting Started with Visual Studio – What Type of Project?
ASP.NET Web Application Project – You may name it: ASP.NET_HandsOn_02
![Page 6: ASP.NET HandsOn 02smiertsc/2336itec/ASP.NET_HandsOn_02.pdfUse a Text Editor? Notepad – bare bones? Notepad – not really feasible with server-side development in ASP.Net Visual](https://reader030.vdocument.in/reader030/viewer/2022041103/5f02c5fc7e708231d405f0e2/html5/thumbnails/6.jpg)
Getting Started with Visual Studio – What’s Different About a Web App???
In Solution Explorer, observe the .aspx extension files
These become the web pages
.aspx extension informs server to parse for server-side execution prior to sending page to client
In Source view of Default.aspx, observe:
XHTML markup
![Page 7: ASP.NET HandsOn 02smiertsc/2336itec/ASP.NET_HandsOn_02.pdfUse a Text Editor? Notepad – bare bones? Notepad – not really feasible with server-side development in ASP.Net Visual](https://reader030.vdocument.in/reader030/viewer/2022041103/5f02c5fc7e708231d405f0e2/html5/thumbnails/7.jpg)
Deitel’s ASP.NET Exercise on Validation Controls – Edit Default. aspx
In Design view, create the interface shown in Figure 25.17
![Page 8: ASP.NET HandsOn 02smiertsc/2336itec/ASP.NET_HandsOn_02.pdfUse a Text Editor? Notepad – bare bones? Notepad – not really feasible with server-side development in ASP.Net Visual](https://reader030.vdocument.in/reader030/viewer/2022041103/5f02c5fc7e708231d405f0e2/html5/thumbnails/8.jpg)
Add a Validator Control
From the toolbox, drag a Required Field Validator Control, placing it beside the text box for the name
![Page 9: ASP.NET HandsOn 02smiertsc/2336itec/ASP.NET_HandsOn_02.pdfUse a Text Editor? Notepad – bare bones? Notepad – not really feasible with server-side development in ASP.Net Visual](https://reader030.vdocument.in/reader030/viewer/2022041103/5f02c5fc7e708231d405f0e2/html5/thumbnails/9.jpg)
Set Properties for the Validator Control
In the Properties window, set values for various properties of the Required Field Validator control
ID = nameInputValidator ControlToValidate = txtName
(select from dropdownlist in Properties Window – so that the ControlToValidate property value matches the name of the name textbox control you added when you designed the interface)
Display = Dynamic ErrorMessage = “You must
enter your name”
![Page 10: ASP.NET HandsOn 02smiertsc/2336itec/ASP.NET_HandsOn_02.pdfUse a Text Editor? Notepad – bare bones? Notepad – not really feasible with server-side development in ASP.Net Visual](https://reader030.vdocument.in/reader030/viewer/2022041103/5f02c5fc7e708231d405f0e2/html5/thumbnails/10.jpg)
Add More Validator Controls
From the toolbox, drag two more Required Field Validator Controls, placing each beside the text boxes for the email address and phone number, respectively. The controls will force all text boxes to have content when a PostBack of the page occurs.
![Page 11: ASP.NET HandsOn 02smiertsc/2336itec/ASP.NET_HandsOn_02.pdfUse a Text Editor? Notepad – bare bones? Notepad – not really feasible with server-side development in ASP.Net Visual](https://reader030.vdocument.in/reader030/viewer/2022041103/5f02c5fc7e708231d405f0e2/html5/thumbnails/11.jpg)
Set Properties for the Validator Controls
In the Properties window, set values for various properties of the Required Field Validator controls you added
ID = emailInputValidator ControlToValidate=txteMail Display=Dynamic ErrorMessage=“Please enter
your email address.”
ID = phoneInputValidator ControlToValidate=txtPhone Display = Dynamic ErrorMessage = “Please enter
your phone number.”
![Page 12: ASP.NET HandsOn 02smiertsc/2336itec/ASP.NET_HandsOn_02.pdfUse a Text Editor? Notepad – bare bones? Notepad – not really feasible with server-side development in ASP.Net Visual](https://reader030.vdocument.in/reader030/viewer/2022041103/5f02c5fc7e708231d405f0e2/html5/thumbnails/12.jpg)
Run the Application
Right click on Default.aspx in Solution Explore and choose Set as Start Page
Save all Build the application Run w/o Debugging Place the cursor in a textbox if it
isn’t already in one If you hit Enter without typing
anything in the text box, then the error message will appear prompting you to fill in the text box
![Page 13: ASP.NET HandsOn 02smiertsc/2336itec/ASP.NET_HandsOn_02.pdfUse a Text Editor? Notepad – bare bones? Notepad – not really feasible with server-side development in ASP.Net Visual](https://reader030.vdocument.in/reader030/viewer/2022041103/5f02c5fc7e708231d405f0e2/html5/thumbnails/13.jpg)
Add a Different Validator Control
From the toolbox, drag a Regular Expression Field Validator Control, placing it beside the text box for the email address
![Page 14: ASP.NET HandsOn 02smiertsc/2336itec/ASP.NET_HandsOn_02.pdfUse a Text Editor? Notepad – bare bones? Notepad – not really feasible with server-side development in ASP.Net Visual](https://reader030.vdocument.in/reader030/viewer/2022041103/5f02c5fc7e708231d405f0e2/html5/thumbnails/14.jpg)
Regular Expressions
A pattern describing a certain amount and layout of text The name comes from mathematical
theory that is the basis for the concept The term “regular expression” is often
abbreviated as regex or regexp
http://www.regular-expressions.info/tutorial.html
![Page 15: ASP.NET HandsOn 02smiertsc/2336itec/ASP.NET_HandsOn_02.pdfUse a Text Editor? Notepad – bare bones? Notepad – not really feasible with server-side development in ASP.Net Visual](https://reader030.vdocument.in/reader030/viewer/2022041103/5f02c5fc7e708231d405f0e2/html5/thumbnails/15.jpg)
Regular Expression
Just when you thought you were THROUGH learning syntax!!!!
A regular expression is a pattern that matches some text \b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b This pattern represents any email address
![Page 16: ASP.NET HandsOn 02smiertsc/2336itec/ASP.NET_HandsOn_02.pdfUse a Text Editor? Notepad – bare bones? Notepad – not really feasible with server-side development in ASP.Net Visual](https://reader030.vdocument.in/reader030/viewer/2022041103/5f02c5fc7e708231d405f0e2/html5/thumbnails/16.jpg)
Regular Expression Info
Go to: http://www.regular-expressions.info/regexbuddy/email.html To see how the pattern expressed by the
regular expression translates to any email address
![Page 17: ASP.NET HandsOn 02smiertsc/2336itec/ASP.NET_HandsOn_02.pdfUse a Text Editor? Notepad – bare bones? Notepad – not really feasible with server-side development in ASP.Net Visual](https://reader030.vdocument.in/reader030/viewer/2022041103/5f02c5fc7e708231d405f0e2/html5/thumbnails/17.jpg)
Set Properties for the Regular Expression Validator Controls
Use the Deitel book as your guide
The property that contain the expression is ValidationExpression
There is a dropdown list of standard regular expressions you can use
Similarly for the phone number validator
![Page 18: ASP.NET HandsOn 02smiertsc/2336itec/ASP.NET_HandsOn_02.pdfUse a Text Editor? Notepad – bare bones? Notepad – not really feasible with server-side development in ASP.Net Visual](https://reader030.vdocument.in/reader030/viewer/2022041103/5f02c5fc7e708231d405f0e2/html5/thumbnails/18.jpg)
Run the Application
Save all Build the application Run w/o Debugging Place the cursor in a textbox if it
isn’t already in one Hit the Enter key after entering
text in a textbox to see the validator controls work
![Page 19: ASP.NET HandsOn 02smiertsc/2336itec/ASP.NET_HandsOn_02.pdfUse a Text Editor? Notepad – bare bones? Notepad – not really feasible with server-side development in ASP.Net Visual](https://reader030.vdocument.in/reader030/viewer/2022041103/5f02c5fc7e708231d405f0e2/html5/thumbnails/19.jpg)
Continue with Deitel Exercise
The Deitel exercise includes a submit button and a label that collects the validated and submitted information It is worth some extra time to get this part
of the exercise working as well Use a Button control to implement the
Submit button The code that needs to be written is in
Figure 25.18
![Page 20: ASP.NET HandsOn 02smiertsc/2336itec/ASP.NET_HandsOn_02.pdfUse a Text Editor? Notepad – bare bones? Notepad – not really feasible with server-side development in ASP.Net Visual](https://reader030.vdocument.in/reader030/viewer/2022041103/5f02c5fc7e708231d405f0e2/html5/thumbnails/20.jpg)
Output After Submit Button and Code Added
![Page 21: ASP.NET HandsOn 02smiertsc/2336itec/ASP.NET_HandsOn_02.pdfUse a Text Editor? Notepad – bare bones? Notepad – not really feasible with server-side development in ASP.Net Visual](https://reader030.vdocument.in/reader030/viewer/2022041103/5f02c5fc7e708231d405f0e2/html5/thumbnails/21.jpg)
View the Page Source to See All the Code the Web Server Generates
All the code that you see in the Page Source is not visible in the Design View of Default.aspx in Visual Studio
Why? Because the Web Server is now
participating in the processing of the web application
The user (innocently) request a page
The server pre-processes what it has in the web application and generates the code + markup+ content that is sent to the browser
Inside of script tags you will see JavaScript that you didn’t write
You will not see ASP.NET code that you did write
![Page 22: ASP.NET HandsOn 02smiertsc/2336itec/ASP.NET_HandsOn_02.pdfUse a Text Editor? Notepad – bare bones? Notepad – not really feasible with server-side development in ASP.Net Visual](https://reader030.vdocument.in/reader030/viewer/2022041103/5f02c5fc7e708231d405f0e2/html5/thumbnails/22.jpg)
Time to Publish?
Uploading the contents of your Web application to the Web server is called publishing
Save all and Build!!!!! DO NOT FORGET TO BUILD IMMEDIATELY PRIOR TO PUBLISH !!!!!!
Choose Publish from the Build menu
Change the Publish Method to FPSE (Front Page Server Extensions)
![Page 23: ASP.NET HandsOn 02smiertsc/2336itec/ASP.NET_HandsOn_02.pdfUse a Text Editor? Notepad – bare bones? Notepad – not really feasible with server-side development in ASP.Net Visual](https://reader030.vdocument.in/reader030/viewer/2022041103/5f02c5fc7e708231d405f0e2/html5/thumbnails/23.jpg)
Publish Your Web App
A subweb named ASP.NET_HandsOn_02 has been created for you under your username web folder
Type the full url as the Target Location:
http://cot-cis2336-01.cougarnet.uh.edu/secnnnnn/username/ASP.NET_HandsOn_02
http://cot-cis2336-01.cougarnet.uh.edu/secnnnnn/username/ASP.NET_HandsOn_02
![Page 24: ASP.NET HandsOn 02smiertsc/2336itec/ASP.NET_HandsOn_02.pdfUse a Text Editor? Notepad – bare bones? Notepad – not really feasible with server-side development in ASP.Net Visual](https://reader030.vdocument.in/reader030/viewer/2022041103/5f02c5fc7e708231d405f0e2/html5/thumbnails/24.jpg)
See the Results (Hopefully You Won’t See Either of These)
![Page 25: ASP.NET HandsOn 02smiertsc/2336itec/ASP.NET_HandsOn_02.pdfUse a Text Editor? Notepad – bare bones? Notepad – not really feasible with server-side development in ASP.Net Visual](https://reader030.vdocument.in/reader030/viewer/2022041103/5f02c5fc7e708231d405f0e2/html5/thumbnails/25.jpg)
If You Do See an Error
It may be because you forgot to build prior to publish
Try the Save All –Build – Publish routine again
Then email me if the error persists
![Page 26: ASP.NET HandsOn 02smiertsc/2336itec/ASP.NET_HandsOn_02.pdfUse a Text Editor? Notepad – bare bones? Notepad – not really feasible with server-side development in ASP.Net Visual](https://reader030.vdocument.in/reader030/viewer/2022041103/5f02c5fc7e708231d405f0e2/html5/thumbnails/26.jpg)
See the Results
![Page 27: ASP.NET HandsOn 02smiertsc/2336itec/ASP.NET_HandsOn_02.pdfUse a Text Editor? Notepad – bare bones? Notepad – not really feasible with server-side development in ASP.Net Visual](https://reader030.vdocument.in/reader030/viewer/2022041103/5f02c5fc7e708231d405f0e2/html5/thumbnails/27.jpg)
ASP.NET Hands-OnLesson 02
By Susan L. Miertschin