CS 3870/CS 5870 Web User Controls.

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.
Introduction to ASP.Net ISYS 350. ASP.NET ASP.NET is a server-side technology for creating dynamic web pages. ASP.NET allows you to use a selection of.
Adding Controls to User Forms. Adding Controls A user form isn’t much use without some controls We’re going to add controls and write code for them Note.
Visual Basic 2008 Express Edition The IDE. Visual Basic 2008 Express The Start Page Recent Projects Open an existing project Create a New Project.
Tutorial: Introduction to ASP.NET Internet Technologies and Web Application 4 th February 2010.
DR.JOHN ABRAHAM PROFESSOR UTPA ASP.NET. ACTIVE SERVER PAGES (ASP) Web application development environment Web applications use web browser to display.
CIS 338: Creating ActiveX Controls Dr. Ralph D. Westfall March, 2003.
ASP.NET Web Application Professor Ralph Westfall May 2011.
Java Programming, 3e Concepts and Techniques Chapter 3 Section 65 – Manipulating Data Using Methods – Java Applet.
INSPIRING CREATIVE AND INNOVATIVE MINDS Module 4: Adding Code to a Microsoft ASP.NET Web Form Implementing Code-Behind Pages Adding Event Procedures to.
Using FrontPage Express. Slide 1 Standard toolbars and menus Time indicator: gives an approximation of download time of the page.
Web Programming: Client/Server Applications Server sends the web pages to the client. –built into Visual Studio for development purposes Client displays.
Creating Custom Controls with User Controls. Including Standard Content with User Controls Global Super Company Global Super Company We mean business!
CSCI 6962: Server-side Design and Programming Introduction to Active Server Pages.
C# Tutorial -1 ASP.NET Web Application with Visual Studio 2005.
1 CS 3870/CS 5870: Note 11 Authentication and Authorization Membership Provider.
CIS 451: USING ASP.NET TO CREATE XML Dr. Ralph D. Westfall February, 2009.
Chapter 7 – Navigation Dr. Stephanos Mavromoustakos.
1 CS 3870/CS 5870 Note04 Session Variables and Post Back.
Joe Hummel, PhD Dept of Mathematics and Computer Science Lake Forest College
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.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 Unit 3: Adding Code to a Microsoft ASP.NET Web Form.
1 CS 3870/CS 5870: Note 13 Lab 6 Authentication and Authorization Roles Management.
1 CS 3870/CS 5870: Note 07 Lab 3 Lab 4 Test 1: Two Tables.
1 Chapter 12: Form Builder Objects and Flexible Code.
CIS 375—Web App Dev II ASP.NET 8 More Binding. 2 The Repeater ControlThe Repeater Control 1 The Repeater control is used to display a repeated list of.
1 CS 3870/CS 5870: Note05 Prog3 Web Application with Database.
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.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
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.
ASP.NET User Controls. User Controls In addition to using Web server controls in your ASP.NET Web pages, you can create your own custom, reusable controls.
Created by Alia Al-Abdulkarim 2008 Visual Basic Vs. Java.
Working With ASP.NET Application. Create a new virtual directory The procedure to create a new virtual directory Internet Services Manager Right click.
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.
MIS 3200 – Unit 5.1 Iteration (looping) – while loops – for loops Working with List Items.
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.
CIS 375—Web App Dev II ASP.NET 4 Server Controls.
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.
1 CS 3870/CS 5870: Note 14. Prog5 Due 10 PM Wednesday, Oct 21 Authentication and Authorization 2.
1 CS 3870/CS 5870: Note07 Prog 4. Master Pages Creating a master page based on another master page MainMasterPage –For all Progs and Tests Prog4MasterPage.
1 CS 3870/CS 5870: Note07 Prog 4. Master Pages Creating a master page based on another master page MainMasterPage –For all Progs and Tests Prog4MasterPage.
1111 Creating ASPX Controls Programatically Objectives You will be able to Dynamically add controls to a page. Dynamically alter properties of controls.
11 User Controls Beginning ASP.NET in C# and VB Chapter 8.
1 CS 3870/CS 5870: Note 19 AJAX Prog8. Test 2 50 Points Thursday, Nov 12 2:00 PM – 4:00 PM Lab
111 State Management Beginning ASP.NET in C# and VB Chapter 4 Pages
Howto: Custom page design Creating your own ASPX page Step-by-step guide.
1. Prog3 Try and Catch Testing 2 Catching Database Errors Protected Sub DetailsView1_ItemDeleted( sender As Object, e As DetailsViewDeletedEventArgs)
Computing with C# and the .NET Framework
ASP.NET Forms.
CS 3870/CS 5870 Web Service.
Unit 7 Learning Objectives
Web Application with Database
Session Variables and Post Back
CS 3870/CS 5870 AJAX Prog8.
Web Application with Dataase
Dr. Ralph D. Westfall June, 2011
CS 3870/CS 5870 Web User Controls Events (II).
CS 3870 Prog5 Shopping Bag.
Add Image and Title to Individual Page
CS 3870 Web User Control Events.
Static and Dynamic Web Pages
Tonga Institute of Higher Education
ASP.NET.
CS 3870/CS 5870 Test 2 (50 points) Thursday
Web Application with Dataase
Using FrontPage Express
ASP.NET 2.0 Overview Created By: Ajay Bahoriya.
Presentation transcript:

CS 3870/CS 5870 Web User Controls

Prog 7 Folder Prog7 Sub-folders Admin Sub-folders Member Prog7MasterPage Default.aspx ShoppingItem.ascx Sub-folders Admin Updating.aspx Sub-folders Member Shopping.aspx Chckout.aspx

Creating ShoppingItem.ascx For page Checkout Add New Items Web User Control File name ShoppingItem.ascx Place code in separate file Different file extension

Adding Controls to ShoppingItem.ascx Same as adding server controls to Web Forms Using default (relative) position, not absolute position Textboxes and label on same line

Setting Properties of Controls Read Only Width Alignment Using Style

Class Prog7_ShoppingItem Partial Class Prog7_ShoppingItem Inherits System.Web.UI.UserControl ‘ Private data Private _theID, _theName As String Private _thePrice, _theCost As Single Private _theQuantity As Integer End Class

Public Properties Partial Class Prog7_ShoppingItem Inherits System.Web.UI.UserControl Public Property theID As String Set(value As String) _theID = value End Set Get Return _theID End Get End Property . . . End Class

Public Properties Partial Class Prog7_ShoppingItem Inherits System.Web.UI.UserControl Public Property theQuantity As Integer Set(value As String) _theQuantity = value End Set Get Return _theQuantity End Get End Property . . . End Class

Public Properties Partial Class Prog7_ShoppingItem Inherits System.Web.UI.UserControl Public Property theCost As Single Set(value As Single) _theCost = value End Set Get Return _theCost End Get End Property . . . End Class

Page Load Event Partial Class Prog7_ShoppingItem Inherits System.Web.UI.UserControl . . . Protected Sub Page_Load(. . .) Handles Me.Load lblMsg.Text = “” txtID.Text = _theID txtName.Text = _theName txtPrice.Text = FormatCurrency(_thePrice) txtQuantity.Text = _theQuantity txtCost.Text = FormatCurrency(_theCost) End Sub End Class

Adding Web User Control at Design Time Prog7/Default.aspx Source view (or design view) Drag and Drop ShoppingItem.ascx to Prog7/Default.aspx If error, close and re-open Default.aspx or re-open VS

Page Directive Register Prog7/Default.aspx Source view <%@ Register Src="~/Prog7/ShoppingItem.ascx" TagPrefix="uc1" TagName="ShoppingItem" %> <asp:Content ID="Content1" . . .Runat="Server"> <h2>Use the TreeView to . . . </h2> <uc1:ShoppingItem runat="server" ID="ShoppingItem" /> </asp:Content>

Page Default.aspx Protected Sub Page_Load(. . .) Handles Me.Load ShoppingItem.theID = "101" ShoppingItem.theQuantity = 20 End Sub

Adding Web User Control at Run Time Must register the control at the design time Drag and Drop or Copy and Paste <%@ Register Src="~/Prog7/ShoppingItem.ascx" TagPrefix="uc1" TagName="ShoppingItem" %>

Shopping Bag Use SortedList

Global.asax Session("Prog7_Bag") = New SortedList

Page Shopping.aspx Protected Sub btnAdd_Click(. . .) Handles btnAdd.Click Dim c1 As Prog7_ShoppingItem Dim bag As SortedList = Session("Prog7_Bag") ‘ Specify file path to load the control ‘ c1 = CType(LoadControl("../ShoppingItem.ascx"), ‘ Prog7_ShoppingItem) ‘ New works here c1 = New Prog7_ShoppingItem End Sub

Page Shopping.aspx Protected Sub btnAdd_Click(. . .) Handles btnAdd.Click . . . c1 = New Prog7_ShoppingItem c1.theID = txtID.Text c1.theQuantity = txtQuanity.Text bag.Remove(c1.theID) bag.Add(c1.theID, c1) End Sub

Page Checkout.aspx Protected Sub Page_Load(. . .) Handles Me.Load Dim c1, c2 As Prog7_ShoppingItem Dim bag As SortedList = Session("Prog7_Bag") ‘ Need to find the form to add the control Dim theForm As Control = Master.Master.FindControl("form1") . . . theForm.Controls.Add(c1) End Sub

Page Checkout.aspx Protected Sub Page_Load(. . .) Handles Me.Load Dim c1, c2 As Prog7_ShoppingItem . . . ‘ New does not work here c1 = CType(LoadControl("../ShoppingItem.ascx"), Prog7_ShoppingItem) c2 = bag.GetByIndex(0) c1.theID = c2.theID c1.theQuantity = c2.theQuantity theForm.Controls.Add(c1) End Sub

Page Checkout.aspx Protected Sub Page_Load(. . .) Handles Me.Load Dim c1, c2 As Prog7_ShoppingItem . . . ‘ Must use a loop to add all items in bag For . . . c1 = CType(LoadControl("../ShoppingItem.ascx"), Prog7_ShoppingItem) c2 = bag.GetByIndex(index) c1.theID = c2.theID c1.theQuantity = c2.theQuantity theForm.Controls.Add(c1) Next End Sub

Page Checkout.aspx Protected Sub Page_Load(. . .) Handles Me.Load Dim c1, c2 As Prog7_ShoppingItem . . . ‘ Must use a loop to add all items in bag For . . . c1 = CType(LoadControl("../ShoppingItem.ascx"), Prog7_ShoppingItem) ‘ Can add c1 to any other control? theForm.Controls.Add(c1) Next End Sub