Chapter 4b: ASP.NET Rich Controls - PowerPoint PPT Presentation

1 / 14
About This Presentation
Title:

Chapter 4b: ASP.NET Rich Controls

Description:

Keyword for sub-grouping banners. Only 1 keyword allowed per ad ... could default that by application, user name provided on a sign-on screen, etc. ... – PowerPoint PPT presentation

Number of Views:1647
Avg rating:3.0/5.0
Slides: 15
Provided by: conest
Category:
Tags: asp | net | banners | chapter | controls | rich | sign

less

Transcript and Presenter's Notes

Title: Chapter 4b: ASP.NET Rich Controls


1
Chapter 4b ASP.NET Rich Controls
Original slides by Kathleen Kalata Dave
Turton Modified by Meyer Tanuan
2
Objectives
  • Create a rotating banner advertisement on the Web
    page using the AdRotator control
  • Create an interactive calendar using the calendar
    control
  • Create ASP.NET pages that allow you to upload a
    file to the Web server

3
AdRotator
  • Change banner each time page is loaded
  • Banner is a hyperlinked image
  • AdScheduler File is an XML document
  • Root element ltAdvertisementsgt
  • Banner element ltAdgt
  • ltImageUrlgt image to be displayed
  • ltNavigateUrlgt hyperlink URL for image
  • ltAlternateTextgt image alt property
  • ltImpressionsgt how often banner is displayed
  • If all Impressions add to 100, and this one's 20,
    it will be displayed 20 times out of 100.
  • ltKeywordgt for sub-grouping banners
  • Only 1 keyword allowed per ad
  • To display only banners whose keyword is "music"

4
lt?xml version"1.0" encoding"utf-8"
?gt ltAdvertisementsgt ltAdgt ltImageUrlgtimages/529.g
iflt/ImageUrlgt ltNavigateUrlgtgetproduct.aspx?id52
9.jpglt/NavigateUrlgt ltAlternateTextgtWaterford
Crystal Card Holderlt/AlternateTextgt ltImpressions
gt20lt/Impressionsgt ltKeywordgtWaterfordlt/Keywordgt
lt/Adgt ltAdgt ltImageUrlgtimages/566.giflt/ImageUrlgt
ltNavigateUrlgtgetproduct.aspx?id566.jpglt/Navigat
eUrlgt ltAlternateTextgtBelleek Colleen
Vaselt/AlternateTextgt ltImpressionsgt10lt/Impression
sgt ltKeywordgtBelleeklt/Keywordgt lt/Adgt ltAdgt ltIm
ageUrlgtimages/555.giflt/ImageUrlgt ltNavigateUrlgtge
tproduct.aspx?id555.jpglt/NavigateUrlgt ltAlternat
eTextgtCashill Clock by Belleeklt/AlternateTextgt lt
Impressionsgt10lt/Impressionsgt ltKeywordgtBelleeklt/K
eywordgt lt/Adgt lt/Advertisementsgt
Will display 20 out of every 40 times
5
AdRotator Control
  • Add control where banner is to display
  • Properties
  • AdvertisementFile XML file of banners
  • KeywordFilter only banners with this keyword
  • (only 1 value allowed)
  • Target where to display hyperlink
  • Height/Width if want the same for all banners

6
XML file of banner info
Only ads with this keyword
7
Calendar Control
  • Interactive calendar
  • User selects a date
  • SelectionChanged event fires
  • SelectedDate property identifies the date
  • Use date manipulation to process
  • myCalendar.SelectedDate.ToShortDateString()
  • When day/week/month selections permitted
  • SelectedDates is a collection of the selected
    dates
  • Count property indicates how many dates selected
  • Use for loop to index through collection (from
    index0)

8
Use SelectedDates collection to process when more
than one day permitted
Use SelectedDate property to process when only
one day permitted
9
Processing Calendar Selection(s)
  • Private Sub CalDay_SelectionChanged(ByVal sender
    As
  • lblDay.Text CalDay.SelectedDate.ToLongDateStri
    ng
  • End Sub
  • Private Sub calWeekDay_SelectionChanged(ByVal
    sender As
  • Dim i As Integer
  • For i 0 To calWeekDay.SelectedDates.Count - 1
  • lblDayWeek.Text calWeekDay.SelectedDates(i)
    .ToLongDateString() "ltbr/gt"
  • Next
  • End Sub

10
File Upload
  • Allow users to upload file to server
  • Browse button on page
  • To select local file to be uploaded
  • You control to which directories
  • User presents a file you code target
    path\filename
  • Individual user rights are not relevant
  • It's the web service doing the writing
  • You can control the file type
  • Add "accept" attribute to ltinput type"filegt
  • Accept"image/jpg, text/css, image/"

11
(HTML control) run as server control
12
Text box for name of file at server (or default
to source file name)
Button to perform upload
Could have provided a text box to input the
target directory or you could default that by
application, user name provided on a sign-on
screen, etc.
13
Upload File Sample Code
  • Private Sub btnUpload_Click(ByVal sender As
  • If txtServerName.Text "" Then
  • lblError.Text "Error need server file-name"
  • Return
  • End If
  • Dim uploadDir As String
  • uploadDir "c\UploadFiles"
  • inBrowse.PostedFile.SaveAs(uploadDir "\"
    txtServerName.Text)
  • End Sub

14
File Field Properties
  • source inBrowse.PostedFile.FileName
  • Get source file-name and path
  • inBrowse.PostedFile.ContentLength
  • Length of file being uploaded
  • Check if it's " Nothing
  • System.IO.Path.GetFileName(source)
  • Get input file-name extension
  • System.IO.Path.GetFileExtension(source)
  • Get input file-name extension
Write a Comment
User Comments (0)
About PowerShow.com