Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 3870/CS 5870 Test 2 (50 points) Thursday 2 - 4.

Similar presentations


Presentation on theme: "CS 3870/CS 5870 Test 2 (50 points) Thursday 2 - 4."— Presentation transcript:

1 CS 3870/CS 5870 Test 2 (50 points) Thursday 2 - 4

2 Accessing Database Code class DataSource Control
Your choice on the test

3 Data Binding GridView DetailsView Textbox DropDownList . . .

4 DetailsView AllowPage For end user For developer

5 Accessing Individual Elements of DetailsView
c.TheID = DetailsView1.Rows(0).Cells(1).Text c.TheName = DetailsView1.Rows(1).Cells(1).Text

6 DropDownList One field of all records DataTextField
DataValueField: PK column

7 DetailsView and DropDownList
Using DropDownList to select records of DetailsView

8 Protected Sub DropDownList1_SelectedIndexChanged (sender As Object, e As EventArgs) Handles DropDownList1.SelectedIndexChanged DetailsView1.PageIndex = DropDownList1.SelectedIndex End Sub

9 PostBack Default True for Buttons
Default False for many other controls

10 Session Variables

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

12 Accessing Session Variables
Protected Sub Page_Load(. . .) Handles Me.Load Dim bag As SortedList = Session("Prog7_Bag") End Sub

13 Web User Control A class Can have other controls Properties Methods
Events

14 Using Web User Control Register Src="~/Prog7/ShoppingItem.ascx" TagPrefix="uc1" TagName="ShoppingItem" %>

15 Placing User Controls on Forms
At design time At run time

16 Adding to Forms at Run Time
Protected Sub Page_Load(. . .) Handles Me.Load ‘ Need to find the form to add the control Dim theForm As Control = Master.Master.FindControl("form1") theForm.Controls.Add(c1) End Sub

17 Adding to Placeholder at Run Time
Protected Sub Page_Load(. . .) Handles Me.Load c1 = CType(LoadControl("../ShoppingItem.ascx"), Prog7_ShoppingItem) PlaceHolder1.Controls.Add(c1) End Sub

18 Adding to Panels at Run Time
Protected Sub Page_Load(. . .) Handles Me.Load c1 = CType(LoadControl("../ShoppingItem.ascx"), Prog7_ShoppingItem) Panel1.Controls.Add(c1) End Sub

19 Web User Control as a Class
Protected Sub btnBag_Click(. . .) Handles btnBag.Click c1 = New Prog7_ShoppingItem End Sub

20 Web User Control NOT as a Class
Protected Sub Page_Load(. . .) Handles Me.Load ‘ New does not work c1 = CType(LoadControl("../ShoppingItem.ascx"), Prog7_ShoppingItem) theForm.Controls.Add(c1) End Sub

21 Public Event Define event Raise event Handle event

22 Test 2 (50 points) Thursday 2 - 4


Download ppt "CS 3870/CS 5870 Test 2 (50 points) Thursday 2 - 4."

Similar presentations


Ads by Google