Sunday, January 27, 2008

Web Design, Development, Search Engine Optimization and Programming

Web Design, Development, Search Engine Optimization and Programming

1. Binding to ArrayList or HashTable you create in code
A. ArrayList: Binds one field, displays in order created
1. Dim alAlpha As New ArrayList()
2. alAlpha.Add("Larry")
3. …
With radiobuttonlistAlpha
.DataSource = alAlpha
.DataBind()
4. End With
5. …
6. radiobuttonlistAlpha.SelectedItem.Text
B. HashTable: Binds two fields (nice!), but displays in own hash order.
1. Dim htAlpha As New Hashtable()
2. htAlpha.Add(“27”,”Larry”) ‘(key,value)
With rblAlpha
.DataSource = htAlpha
.DataTextField = "Value"
.DataValueField = "Key"
.DataBind()
3. End With
C. Folder: Binds to the directory info object
1. Dim dirInfo As New DirectoryInfo("path to folder")
With rbtFilesList
.DataSource = dirInfo.GetFiles
.DataTextField = "Name"
.DataValueField = "FullName"
.DataBind()
End With
2. CheckBoxList & RadioButtonList (hint. Think Check Box Repeater….)
A. Allows you to bind a data source to a “group of boxes or radio buttons”
B. Check boxes allow more than one choice
C. Radio buttons allow only one to be selected from the group.
D. Both use standard binding code.
1. Example bind to datareader.
With rblEmployees
.DataSource = dr
.DataTextField = "Name"
.DataValueField = "EmployeeID"
.DataBind()
2. End With
3. Formatting:
A. Easy…check the properties….cols, table, vertical vs horizontal.
4. Get “selected values”
A. RadioButtonList: Items collection is all the buttons…selectedIndex is the index of the one that is selected….so you get the Item (button) selected
1. Then return the property you want from that item…ie .Value
2. rblEmployees.Items(rblEmployees.SelectedIndex).Value
B. CheckBoxList…have to loop through and see what is selected
For intCnt = 0 To cblOrders.Items.Count - 1
If cblOrders.Items(intCnt).Selected Then
Do something with … cblOrders.Items(intCnt).Value)
End If
Next
5. Calendar: Cool but costs lots of screen real estate.
A. Right click to Auto format
calBirthdate.SelectedDate = CDate(dr("BirthDate"))
calBirthdate.VisibleDate = CDate(dr("BirthDate"))
B. .SelectedDate is date the user selects but set but does not automatically show that date.
1. .VisibleDate is the date to display. You have to set both
C. calBirthdate_SelectionChanged event is triggered when user selects a new date.
1. This is where code goes to save the date.
6. AdRotator Control
A. Displays new image with each rendering
B. Key is the XML Advertisement file you hand write.
1. photo to show
2. is where to go if you click on the picture
3. text if no images permitted or tool tip
4. relative frequency to show this image
5. used to filter which ones to show.
C. Tip…copy the sample xml and modify
D. Set the .AdvertisementFile property to that xml file and it’s good to go.
E. Hint: Picture is stretched to fit the control.
7. Placeholder and Literal control
A. Takes place of old DHTML’s insertAdjacent etc… builds content the fly.
B. Literal control: used in code to hold HTML text “object”
1. Dim lit As New System.Web.UI.WebControls.Literal()
2. lit.Text = "

"
C. Placeholder control: An invisible box (container) to hold controls you create on the fly.
D. Following code is a sub routine to add a hyperlink control if you supply the URL, Display Text and control ID.
Private Sub MakeLink(ByVal URL As String, ByVal Text As String, ByVal ID As String)
Dim hyp As New HyperLink()
Dim lit As New System.Web.UI.WebControls.Literal()

With hyp
.NavigateUrl = URL
.Text = Text
.ID = ID
End With

plcDemo.Controls.Add(hyp)
lit.Text = "

"
plcDemo.Controls.Add(lit)
1. End Sub