CS 3870/CS 5870 Web User Controls Events (II).

Slides:



Advertisements
Similar presentations
Unit 02. ASP.NET Introduction HTML & Server controls Postbacks Page Lifecycle.
Advertisements

1 CS 3870/CS 5870: Lab4 Save with Invalid Price Keep Order After Updating.
Basics of ASP.NET. 2 © UW Business School, University of Washington 2004 Outline Installing ASP.NET and Web Matrix Data Types Branching Structure Procedures.
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
JavaScript & jQuery the missing manual Chapter 11
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
Beginning Web Site Development Module 1 – Dynamic Web Site Development Fundamentals of building dynamic Web sites with ASP.NET 2.0 and C# Version.
Microsoft Visual Basic 2008 CHAPTER 8 Using Procedures and Exception Handling.
© Minder Chen, ASP.NET 2.0: Introduction - 1 ASP.NET 2.0 Minder Chen, Ph.D. Framework Base Class Library ADO.NET: Data & XML.
Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 1.
1 CS 3870/CS 5870: Note 11 Authentication and Authorization Membership Provider.
VB Core II Conditional statements Exception handling Loops Arrays Debugging.
110-G1 Motivation: Within a program, may have to perform the same computation over and over Many programs share the same computation (e.g. sorting) To.
1 CS 3870/CS 5870 Note04 Session Variables and Post Back.
1 Chapter 12 – Web Applications 12.1 Programming for the Web, Part I 12.2 Programming for the Web, Part II 12.3 Using Databases in Web Programs.
Christopher M. Pascucci Basic Structural Concepts of.NET Managing State & Scope.
Overview of Previous Lesson(s) Over View  SDI programs  The Application Wizard can generate single-document interface (SDI) applications that work.
1 CS 3870/CS 5870: Note 13 Lab 6 Authentication and Authorization Roles Management.
Dynamic Dropdown Lists 1. Objectives You will be able to Use Dropdown Lists to solicit multiple choice user input in an ASPX web page. Populate a Dropdown.
1 CS 3870/CS 5870: Note 07 Lab 3 Lab 4 Test 1: Two Tables.
MS Visual Basic Applications Walter Milner. Event-driven programming Standard approach for GUIs Contrast with old character interfaces – program determines.
BIT 285: ( Web) Application Programming Lecture 06: Thursday, January 22, 2015 Page Object, The Lifetime of a Web Application, Application State and Session.
1 CS 3870/CS 5870: Note05 Prog3 Web Application with Database.
The Problem of State. We will look at… Sometimes web development is just plain weird! Internet / World Wide Web Aspects of their operation The role of.
Two Forms Please use speaker notes for additional information!
The Module Road Map Assignment 1 Road Map We will look at… Internet / World Wide Web Aspects of their operation The role of clients and servers ASPX.
4-1 Chapter 4 The Selection Process in VB.NET. 4-2 Learning Objectives Understand the importance of the selection process in programming. Describe the.
1 CS 3870/CS 5870: Note 20 Web Service. 2 What is Web Service? Providing functionality online to other applications, Web and Windows applications. The.
1 CS387/CS587: Note 08 Shopping Bag DataTable. 2 DataClass Public Shared Function NewShoppingBag() As Data.DataTable Dim bag As New Data.DataTable bag.Columns.Add("Product.
1 CS387/CS587: Note05 Lab 3. 2 Global.asax Must not be under any sub-folder Application_Start Application_End Application_Error Session_Start Session_End.
1 CS 3870/CS 5870: Note 12 Authentication and Authorization Membership Provider.
1.NET Web Forms ADO.NET Structure © 2002 by Jerry Post.
1 Chapter 4 – Decisions 4.1 Relational and Logical Operators (see other set of slides) 4.2 If Blocks (see other set of slides) 4.3 Select Case Blocks (see.
MIS 3200 – Unit 3.2 Page_Load method AutoPostBack property of controls IsPostBack method of the Page object Understanding web page life cycle.
1 CS 3870/CS 5870: Note 16 Web User Controls. Prog 7 Copy Prog6 to Prog7 Modify all files for Prog7 Remove Web.config from sub-folders Make sure Prog7.
Week Procedures And Functions 7 A procedure is a collection of statements that performs a task.
1 CS387/CS587: Note04 Lab 3. 2 Master Page All Web pages will be similar Should be created before other web pages Add New Items Controls on the Master.
1 CS 3870/CS 5870: Note 13 Web Service. 2 What is Web Service? Providing functionality online to other Web applications SOAP Simple Object Access Protocol.
CIS 375—Web App Dev II ASP.NET 5 Events. 2 The Page_Load Event The Page_Load event is triggered when a page loads. [Example]Example Sub Page_Load lbl1.Text="The.
1.NET Web Forms Applications: Main Form © 2002 by Jerry Post.
1 CS 3870/CS 5870: Note 14. Prog5 Due 10 PM Wednesday, Oct 21 Authentication and Authorization 2.
Starting Out with Visual Basic.NET 2 nd Edition Chapter 6 Sub Procedures And Functions.
 ASP.NET provides an event based programming model that simplifies web programming  All GUI applications are incomplete without enabling actions  These.
Beginning ASP.NET in C# and VB Chapter 9
Visual Basic Declaring Variables Dim x as Integer = 0 In the statement above, x is being declared as an Integer (whole number) and is initialised.
111 State Management Beginning ASP.NET in C# and VB Chapter 4 Pages
1. Prog3 Try and Catch Testing 2 Catching Database Errors Protected Sub DetailsView1_ItemDeleted( sender As Object, e As DetailsViewDeletedEventArgs)
Sub Procedures And Functions
Visual Basic Fundamental Concepts
ASP.NET Forms.
CS 3870/CS 5870 Web Service.
Web Application with Database
CS 3870/CS 5870 Web User Controls.
Session Variables and Post Back
Visual programming Chapter 1: Introduction
Indexer AKEEL AHMED.
Using Procedures and Exception Handling
Visual Basic..
Boolean Expressions and If statements
Anatomy of an ASP.NET Page
CS 3870 Web User Control Events.
Do … Loop Until (condition is true)
Tonga Institute of Higher Education
Additional Topics in VB.NET
CS 3870/CS 5870 Test 2 (50 points) Thursday
Active-X Calendar Control
STARTING OUT WITH Visual Basic 2008
PHP an introduction.
5/6/2019 Session 8.2 Postback, ViewState
Overview of the IDE Visual Studio .NET is Microsoft’s Integrated Development Environment (IDE) for creating, running and debugging programs (also.
Presentation transcript:

CS 3870/CS 5870 Web User Controls Events (II)

Public Event Define event Raise event Handle event Create Event Handler Specify Event Handler

Test2 Event of User Control Run my TestTwo locally

Test2 Event works when one item becomes invalid. But may not work if multiple items are invalid.

Debugging Break Points Step Over Continue Stop

Dynamic Pages User request a dynamic page Request a page (first time) Post back Revisit a page ASP.NET generates the requested page User receives a new page

Generating Dynamic Pages Init Load State Process PostBack Data Load PostBack Events Save State Render Unload

Generating Dynamic Pages with User Controls Loading Page Loading User Controls Events triggered by loading user controls PostBack Events

Other Items Could Be Invalid Private Sub EventHandler(ByVal item As TestTwo_CourseAndCredit, ByVal valid As Boolean) If Not valid Then txtTotal.Text = "" Exit Sub End If . . . For index = 0 To bag.Count - 1 c1 = bag.GetByIndex(index) If c1.CourseID = item.CourseID Then c1.Credits = item.Credits total += c1.Credits Next txtCredits.Text = total End Sub

CourseAndCredit.ascx Partial Class TestTwo_CourseAndCredit Inherits System.Web.UI.UserControl ‘ Private data Private _courseID, _courseName As String ‘Private _credits As Integer Private _credits As String Private _valid As Boolean = True Private _message As String = “” End Class

User Control Load Event Protected Sub TestTwo_CourseAndCredit_Load (. . .) Handles Me.Load txtID.Text = _courseID txtName.Text = _courseName txtCredits.Text = _credits lblMsg.Text = _message End Sub

Define Event Partial Class Prog7_ShoppingItem . . . ‘Public Event CreditsChanged(ByVal item As ‘ TestTwo_CourseAndCredit, ByVal valid As Boolean) Public Event CreditsChanged(ByVal item As TestTwo_CourseAndCredit) End Class

Raise Event ‘ Update the object and raise event Protected Sub txtCredits_TextChanged(…) Handles … ‘ update _valid ‘ update message ‘ update _credits ‘ display message RaiseEvent CreditsChanged(Me) End Sub

Raise Event Dim credits As Integer If Integer.TryParse(txtCredits.Text, credits) Then If credits <= 0 Then _message = "Not positive" _valid = False ElseIf credits > 5 Then _message = "Larger than 5" Else _message = "" _valid = True End If _message = "Not an integer" _credits = txtCredits.Text lblMessage.Text = _message RaiseEvent CreditsChanged(Me)

Add Event Handler Protected Sub Page_Load(. . .) Handles Me.Load c1 = CType(LoadControl("../CourseAndCredit.ascx"), TestTwo_CourseAndCredit) AddHandler c1.CreditsChanged, AddressOf HandleChangeEvent theForm.Controls.Add(c1) End Sub

Private Sub HandleChangeEvent(ByVal Item Private Sub HandleChangeEvent(ByVal Item . . . ) Dim allValid as Boolean = True Dim total As Integer = 0 For i = 0 To bag.Count - 1 c = bag.GetByIndex(i) If c.theID = item.theID Then ‘ update the item in the bag End If If c.Valid Then total += c.theCredits Else allValid = False Next If allValid Then txtTotal.Text = total txtTotal.Text = “” End Sub

Web User Control Must Work Correctly At All Times! Prog 6 Web User Control Must Work Correctly At All Times!

Session Variables Display the previously selected Course Prog 6 Session Variables Display the previously selected Course

Prog 6 Copy Prog7 folder Paste as Prog6 folder Modify all files of Prog6 Make sure it works as Prog7 Then Work on Prog6!