12/9/2018 Session 9.1 Calendar and Validation Controls Using Sessions

Slides:



Advertisements
Similar presentations
Tutorial 6 Creating a Web Form
Advertisements

JavaScript Forms Form Validation Cookies. What JavaScript can do  Control document appearance and content  Control the browser  Interact with user.
Asp.NET Core Vaidation Controls. Slide 2 ASP.NET Validation Controls (Introduction) The ASP.NET validation controls can be used to validate data on the.
Tutorial 6 Working with Web Forms
Microsoft Visual Basic 2012 CHAPTER NINE Creating Web Applications.
ASP.NET Validating user input Validating user input on the client and/or server side 1ASP.NET Validating User Input.
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
ASP.NET Programming with C# and SQL Server First Edition
Javascript and the Web Whys and Hows of Javascript.
Tutorial: Introduction to ASP.NET Internet Technologies and Web Application 4 th February 2010.
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
Database-Driven Web Sites, Second Edition1 Chapter 8 Processing ASP.NET Web Forms and Working With Server Controls.
Module 7: Validating User Input.
Chapter 3 Using Validation Controls. What is a Validation Control? A control that validates the value in another control Renders as an HTML tag with an.
1 Presented by Bikash Shrestha. 2 What is ASP.NET or ASP+? ASP.NET/ASP+ is a programming framework built on the common language runtime that can be used.
1 Web-Enabled Decision Support Systems Introduction to ASP.NET Prof. Name Position (123) University Name.
Joe Hummel, PhD Dept of Mathematics and Computer Science Lake Forest College
Telerik Software Academy ASP.NET Web Forms Data Validation, Data Validators, Validation Groups Telerik Software Academy
Overview of Previous Lesson(s) Over View  Server controls are small building blocks of the graphical user interface, which includes  Text boxes  Buttons.
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
Programming with Microsoft Visual Basic 2012 Chapter 12: Web Applications.
XP New Perspectives on Browser and Basics Tutorial 1 1 Browser and Basics Tutorial 1.
Chapter 71 Building Data-Driven ASP.NET Applications Introduction to ASP.NET By Kathleen Kalata.
ASP.Net, Web Forms and Web Controls 1 Outline Web Controls Text and Graphics Controls AdRotator Control Validation Controls.
Web Programming: Client/Server Applications Server sends the web pages to the client. –built into Visual Studio for development purposes Client displays.
© Minder Chen, ASP.NET 2.0: Introduction - 1 ASP.NET 2.0 Minder Chen, Ph.D. Framework Base Class Library ADO.NET: Data & XML.
Validation and Rich controls 1www.tech.findforinfo.com.
Tutorial 121 Creating a New Web Forms Page You will find that creating Web Forms is similar to creating traditional Windows applications in Visual Basic.
Microsoft Visual Basic 2008 CHAPTER SEVEN Creating Web Applications.
Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 1.
Microsoft Visual Basic 2005 CHAPTER 7 Creating Web Applications.
Unit 8.3 Learning Objectives Insert users into the ASP.NET Membership system from code Capture data being sent to the database Capture Exceptions that.
 Whether using paper forms or forms on the web, forms are used for gathering information. User enter information into designated areas, or fields. Forms.
Lesson 12 Adding Validation To The Movie Database.
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company ASP.NET Validation Control Presented By : Muhammad Atif Hussain Deputy.
VALIDATION CONTROLS.  Validation Controls are primarily used to validate, or verify the data entered by user into a web form.  Validation controls attempt.
Reference: “ASP.NET 2.0 Illustrated” by Alex Homer and Dave Sussman. -ch3 illustrated book
ASP.Net, Web Forms and Web Controls 1 Outline Session Tracking Cookies Session Tracking with HttpSessionState.
ASP.NET 4 Unleashed Chapter 1. .aspx page: contains C# script and HTML code including tags. Listing 1.1 FirstPage.aspx.
BlackBerry Applications using Microsoft Visual Studio and Database Handling.
Session 6: Validating User Input. Outline Overview of User Input Validation Client-Side and Server-Side Validation ASP.NET Validation Controls Using Validation.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 User Input Validating.
Vijayalakshmi G M Validation Controls.
ASP.NET Data Binding. Slide 2 Lecture Overview Understanding the ASP.NET data binding model.
Beginning ASP.NET in C# and VB Chapter 9
Tutorial 6 Creating a Web Form
Using Personalization Creating user profiles Retrieving, changing, and saving profile properties Using validation controls Using the Forms Designer.
111 State Management Beginning ASP.NET in C# and VB Chapter 4 Pages
Validation Controls Assist your users with providing the correct type of input for your application Assist your users with providing the correct type of.
2440: 141 Web Site Administration Web Forms Instructor: Joseph Nattey.
>> Form Data Validation in JavaScript
Validation & Rich Controls
Weebly Elements, Continued
Web Application Web Application are programs that can be executed either on a Web server or in a Web browser. An Online store accessed through a browser.
How to Write Web Forms By Mimi Opkins.
Section 17.1 Section 17.2 Add an audio file using HTML
Web Development & Design Foundations with HTML5 7th Edition
Creating Web Applications
Unit 27 - Web Server Scripting
Integrating JavaScript and HTML
Tutorial 6 Creating Dynamic Pages
Static and Dynamic Web Pages
PART 2.
PROG Advanced Web Apps 2/24/2019 Session 9.2 Data Binding Wendi Jollymore, ACES.
5/6/2019 Session 8.2 Postback, ViewState
MIS 3200 – Unit 2.2 Outline What’s the problem with bad data?
Programming with Microsoft Visual Basic 2008 Fourth Edition
Server Controls Validation Controls
Web Programming and Design
Validation & Rich Controls
Presentation transcript:

PROG11044 - Advanced Web Apps 12/9/2018 Session 9.1 Calendar and Validation Controls Using Sessions Wendi Jollymore, ACES

Review Postback Page processing ViewState The return trip from the server Page processing How it works (steps) How the first load is different from postback ViewState Hidden __VIEWSTATE field Using hash array 12/9/2018 Wendi Jollymore, ACES

Calendar Control Properties: SelectedDate VisibleDate Note that: Contains a DateTime object Set when user clicks a date on the control Can be initialized or set at run time VisibleDate The current month that’s visible To set, use the 1st of the month Note that: Selected date can stay the same even as visible date changes 12/9/2018 Wendi Jollymore, ACES

Calendar Control Events SelectionChanged VisibleMonthChanged Occurs when selected date changes User clicks a day, month selector, or week selector Change SelelectionMode property to allow selection of weeks and month VisibleMonthChanged Occurs when user navigates months Does not imply that selection changes! 12/9/2018 Wendi Jollymore, ACES

DateTime Class Constructor: DateTime(int year, int month, int day) Constructs a new DateTime instance for the current year/month/day 12/9/2018 Wendi Jollymore, ACES

DateTime Class Properties: Date Day Contains a DateTime object for the current DateTime instance Time set to midnight Day Contains the day of the month for the current DateTime instance Int32, 1 to 31 12/9/2018 Wendi Jollymore, ACES

DateTime Class Properties: DayOfWeek Month Year A DayOfWeek enumeration value for the day of the week E.g DayOfWeek.Sunday = 0 Month The month # for the current DateTime instance 1 to 12 Year The year for the current DateTime instance 12/9/2018 Wendi Jollymore, ACES

DateTime Class Properties: Now Today Contains a DateTime object representing the computer’s current date and time Static property Today Like DateTime.Now, but without the time (midnight) 12/9/2018 Wendi Jollymore, ACES

DateTime Class Methods: AddDays(int days) AddMonths(int months) Adds the specified number of days to the current DateTime instance Returns a new DateTime instance AddMonths(int months) As above, but adds specified number of months AddYears(int years) As above, but adds specified number of years 12/9/2018 Wendi Jollymore, ACES

DateTime Class Methods: Compare(DateTime d1, DateTime d2) Static method that takes two DateTime objects and returns Int32 Return value: Is less than 0  d1 is earlier than d2 Is greater than 0  d1 is later than d2 Is 0  d1 and d2 are the same date/time 12/9/2018 Wendi Jollymore, ACES

DateTime Class Methods: CompareTo(DateTime d1) Non-static method compares d1 with current DateTime instance Returns Int32, also: Less than 0  current instance is earlier than d1 Greater than 0  current instance is later than d1 Equal to 0  current instance and d1 are the same 12/9/2018 Wendi Jollymore, ACES

DateTime Class Methods: IsLeapYear(int year) Static method, returns boolean True of year is a leap year False if year isn’t a leap year ToString(), ToShortDateString(), ToLongDateString() Returns various String representations of the current DateTime instance 12/9/2018 Wendi Jollymore, ACES

Exercise Add a Calendar control to a new page Use the AutoFormat item in the task menu to format your calendar You an customize by using the “Styles” category of properties in the Properties window Add code to page load to init the calendar to today’s date: Only if this is the first load i.e. IsPostback == False! 12/9/2018 Wendi Jollymore, ACES

Calendar Tutorial Complete the Calendar tutorial in the notes (ASP.NET/Controls and Events) 12/9/2018 Wendi Jollymore, ACES

Validation Controls A set of controls that do client-side validation Controls are rendered as JavaScript Types of Controls: CompareValidator RangeValidator RegularExpressionValidator RequiredFieldValidator CustomValidator 12/9/2018 Wendi Jollymore, ACES

Validation Controls Common Properties: Display ErrorMessage How the control is displayed on the page Static – error message part takes up space, even when not showing Dynamic – no space taken up by control when no error message None – don’t show error message at all ErrorMessage The error message to display Used by a ValidationSummary control 12/9/2018 Wendi Jollymore, ACES

Validation Controls Common Properties: Text ControlToValidate The text the control will display on the page when there’s an error When this is empty, contents of ErrorMessage property are shown instead ControlToValidate The ID of the control that this validator is validating ValidationGroup Set to a group name if you have multiple groups of controls to validate separately 12/9/2018 Wendi Jollymore, ACES

Validation Controls Try it out… set this up: 12/9/2018 Wendi Jollymore, ACES

Validation Controls Drag a RequiredFieldValidator to the right of the first text box ID: valReqEmail ControlToValidate: id of first email box ErrorMessage: “You must enter an email address.” Display: Dynamic Load page and click button without typing email address. Add another of these validators for the “confirm email” text box (valReqConfirm) 12/9/2018 Wendi Jollymore, ACES

Validation Controls Add a RegularExpressionValidator beside valReqEmail ID: valGoodEmail ErrorMessage: “Your email address isn’t valid.” ControlToValidate: ID of email text box Display: Dyanmic ValidationExpression: Should be set to a regular expression Choose “Internet E-Mail Address” from the list 12/9/2018 Wendi Jollymore, ACES

Validation Controls Add a CompareValidator beside valReqConfirm ID: valEmailsMatch ErrorMessage: “Your email address doesn’t match.” ControlToValidate: ID of confirm text box Display: Dyanmic ControlToCompare: Should be the ID of the control you want to compare to – set to ID of email text box ValueToCompare property is used if you want to compare to a static value, instead 12/9/2018 Wendi Jollymore, ACES

Exercise Do the Validation exercises in the notes ASP.NET / Controls and Events 12/9/2018 Wendi Jollymore, ACES

Sessions What is a Session? The time a visitor spends on the web site Starts when they first loads a page Ends when they leave your site, or the session automatically expires Identified by a unique ID stored in a session cookie Cookieless sessions can be used by storing id in the URL You can store information in the Session object A hash table Can store entire objects, not just data Session data is stored on server 12/9/2018 Wendi Jollymore, ACES

Sessions You can store data in a session like you would in ViewState: Session[“userName”] = “Kaluha”; The session variable is called userName The value of the userName variable is “Kaluha” 12/9/2018 Wendi Jollymore, ACES

Sessions Tutorial Do the Sessions Tutorial in the notes ASP.NET / Maintaining State / Sessions Download the images! Set up the page as instructed 12/9/2018 Wendi Jollymore, ACES

Sessions Tutorial Repeater control: Repeats a set of markup/objects You format the templates and it repeats them You bind the control to a data source It will fill the template with your data values The repeater will be linked to a hash table of items and quantities Book title will be key Quantity will be value 12/9/2018 Wendi Jollymore, ACES

Sessions Tutorial <ItemTemplate> … </ItemTemplate> Defines each “row item” in the repeater control Each row in the control will be as defined in the template 12/9/2018 Wendi Jollymore, ACES

Sessions Tutorial <asp:Label ID="Label1" width="70" runat="server" text='<%# ... %>'> </asp:Label> <%# %> tags are for inline data binding expressions Single quotes around text attribute value because inline expression requires double-quotes The expression will be evaluated and result will appear in this label’s Text property 12/9/2018 Wendi Jollymore, ACES

Sessions Tutorial Container.DataItem DictionaryEntry is a class ((DictionaryEntry)Container.DataItem) Container.DataItem Refers to a specific item of data bound to the current container Current container is the repeater template Data Item will be an element in the hash table DictionaryEntry is a class Models a piece of data with a key/value pair Has a Key property that contains the key portion, and Value property for value Cast DataItem into DictionaryEntry so we can use the Key and Value properties 12/9/2018 Wendi Jollymore, ACES

Sessions Tutorial basketList.DataSource = basketTable; basketList.DataBind(); DataSource property The source of the data that will fill this control Can be a hash table, data set, and other stuff you’ll learn later in the course DataBind() method Gets the data from the data source and populates the control 12/9/2018 Wendi Jollymore, ACES

Sessions Tutorial Do the portion of the tutorial that takes you through the code Session[“basket”] = basketTable; Stores a reference to the basketTable hash table in the Session variable basket Page_Prerender() event Executes after control events have been executed, but before HTML is rendered We need the results from the event handler in order to update the repeater Page_Load is too soon, as it executes before the event handler 12/9/2018 Wendi Jollymore, ACES

For Next Class.. That last tutorial introduced Data Binding We’ll look at this in more detail in the next class 12/9/2018 Wendi Jollymore, ACES