Jasinski Technical Wiki

Navigation

Home Page
Index
All Pages

Quick Search
»
Advanced Search »

Contributor Links

Create a new Page
Administration
File Management
Login/Logout
Your Profile

Other Wiki Sections

Software

PoweredBy

Chapter 04: Using Server Controls - MCTS Exam 70-515

RSS
Modified on Wed, Dec 28, 2011, 3:20 PM by Administrator Paths: MCTS Exam 70-515 Categorized as MCTS Exam 70-515

Table of Contents [Hide/Show]


   Lesson 1: Exploring Common Server Controls
      Label Control
      Literal Control
      TextBox Control
      ChecBox Control
      RadioButton Control
      DropDownList Control
      ListBox Control
      Button Control
      HTML Server Controls
   Lesson 2: Exploring Specialized Server Controls
      Table, TableRow, and TableCell
      Image
      ImageButton
      ImageMap
      Calendar
      FileUpload
      Panel
      MultiView and View
      Wizard
      Xml


Lesson 1: Exploring Common Server Controls

Label Control

  • AccessKey property — The key, when pressed with the Alt key, to be associated to the Label
  • AssociatedControlID property — The control to associate to the label. Focus is set to this control when the user presses the AccessKey.

Literal Control

The Mode property determines how the Text property gets rendered

ModeDescription
PassThroughThe Text content is rendered as is.
EncodeThe Text content is HTML-encoded. For security reasons, use this mode when rendering user input.
TransformThe Text content is converted to match the markup language of the requesting browser, such as HTML, XHTML, WML, or cHTML

TextBox Control

  • TextMode property — SingleLine (default), MultiLine, or Password.
  • Columns and Rows properties — used with MultiLine TextMode.
  • MaxLength property — limits the number of characters accepted
  • Wrap property — default = True.
  • TextChanged event

ChecBox Control

  • TextAlign property — determines on which side of the checkbox the caption appears
  • CheckedChanged event — Doesn't cause a postback unless AutoPostBack property is True.

RadioButton Control

  • GroupName property — the means to group RadioButton controls
  • TextAlign property — determines on which side of the checkbox the caption appears
  • CheckedChanged event — Doesn't cause a postback unless AutoPostBack property is True.

DropDownList Control

  • Items.Add method — to add items
  • SelectedIndex and SelectedValue properties
  • SelectedIndexChanged event

ListBox Control

  • SelectionMode property — set to Multiple

Button Control

  • Can be a submit button (default) or a command button.
  • Submit button: Handle the Click event.
  • Command button: Use CommandName and CommandArgument properties and handle the Command event.

HTML Server Controls

  • Coded with HTML tags, with the addition of the runat="server" attribute.

Lesson 2: Exploring Specialized Server Controls

Table, TableRow, and TableCell

  • Don't confuse Table with HtmlTable, which is an HTML Server Control.
  • For static content, an HTML table is more efficient.
  • To add a row: Table1.Rows.Add(new TableRow());
  • To add a cell: TableRow1.Cells.Add(new TableCell());

Image

  • ImageUrl — Virtual path to the image.
  • AlternateText property — displayed when the image isn't found
  • ImageAlign property — NotSet, Left, Right, Baseline, Top, Middle, Bottom, AbsBottom, AbsMiddle, or TextTop
  • DescriptionUrl property — sets the longdesc attribute, which is used for accessibility
  • GenerateEmptyAlternateText property — Setting to True generates the alt="" attribute, which is recommended for images that don't contribute meaning to the content, such as a blank or page divider images.
  • NO Click EVENT!

ImageButton

  • Same as Image control, but clickable
  • Click event — ImageClickEventArgs contacts (X,Y) coordinates of the point clicked
  • Command event

ImageMap

  • Same as Image but clickable, and with an image map (usemap="#myMap" attribute)
  • Has HotSpot elements (CircleHotSpot, RectangleHotSpot, or PolygonHotSpot), each with the following properties

PropertyDescription
AccessKey, AlternateText, NavigateUrl, TabIndexSame as for other controls
HotSpotModeWhat happens when the hot spot is clicked: NotSet, Inactive, Navigate (default), or PostBack
NavigateUrl, TargetSame as for HyperLink control
PostBackValueString argument passed back to the server via EventArg property

Calendar

  • SelectionChanged event — causes a postback when the user selects a date
  • VisibleMonthChanged event — causes a postback when the user views a different month

PropertyDescription
Caption The text that is rendered in the Calendar.
CaptionAlign The alignment of the caption: Top, Bottom, Left, Right, or NotSet.
CellPadding The space between each cell and the cell border.
CellSpacing The spacing between each cell.
DayHeaderStyle The style to be applied to days of the week.
DayNameFormat The format for the names of the days of the week: FirstLetter, FirstTwoLetters, Full, Short, Shortest.
DayStyle The default style for a calendar day.
FirstDayOfWeek The day of the week to display in the first column of the Calendar control.
NextMonthText The text to be displayed in the next month navigation control; > is the default. This navigational control is only displayed if ShowNextPrevMonth property is true.
UseAccessibleHeader A control that, when set to true, generates <th> for day headers (the default), or, when set to false, generates <td> for day headers, to be compatible with version 1.0 of the .NET Framework.
VisibleDate Specifies the date that identifies which month to display in the Calendar control’s header area.
WeekendDayStyle The style of weekend days.

FileUpload

  • Does NOT cause postback when a file is selected; a postback by another control (e.g., a Button) causes the file to uploaded as posted data.
  • FileBytes property — The file exposed as a byte array
  • FileContent property — The file exposed as a stream
  • PostedFile property — The file exposed as HttpPostedFile object.
  • SaveAs method — saves the uploaded file to the server.
  • Largest file allowed set by web.config/configuration/httpRuntime/MaxRequestLength

Panel

  • BackgroundImageUrl property
  • HorizontalAlignment property
  • Wrap property
  • DefaultButton property

MultiView and View

  • A MultiView is a container for multiple View children, which are each container controls.
  • At most one View is shown at a time.
  • ActiveViewIndex property and SetActiveView method — get/set the View programmatically; If ActiveViewIndex is -1, no views are visible.

Wizard



Xml

ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2018, Patrick Jasinski.