Chapter 05: Input Validation and Site Navigation - MCTS Exam 70-515

Lesson 1: Input Validation

Common Properties

Validation Controls

Page Members

Lesson 2: Site Navigation

Client-Side Navigation

Cross-Page Posting

Client-Side Browser Redirect

Server-Side Transfer

SiteMap Files and the SiteMap Class

Lesson 3: Web Parts


ControlDescriptionHosted Within
WebPartManager invisible control required on every page that includes Web Parts(not applicable)
WebPartA component of pre-defined functionality that can be added to, removed from, and moved around on a web page by the developer or the user.WebPartZone
CatalogPart UI for managing a group of available Web PartsCatalogZone
PageCatalogPart similar to CatalogPart, but only groups those Web Parts that are part of a specific page; can be used, for example, to return a Web Part to a page on which it's been closed.CatalogZone
EditorPart allows user customizationsEditorZone
DeclarativeCatalogPart allows developer to declare Web Parts available to a page or the entire site(not applicable)


Enabling User Arrangement and Editing

Change the display mode of the page via the WebPartManager control's DisplayMode property, which has the following settings.

Display ModeDescription
BrowseDisplayModeDefault mode in which users view content
DesignDisplayModeEnables dragging of web parts
EditDisplayModeEnabled dragging and editing (title, size, direction, appearance, and zone). Requires an EditorZone cotnrol, plus either an AppearanceEditorPart and LayoutEditorPart control, on the page
CatalogDisplayModeEnabled adding of web parts. Requires a CatalogZone control on the page
ConnectDisplayModeEnables connecting controls via a ConnectionZone control on the page

Connecting Web Parts with Static Connections

1. Create a provider web part (either a user control, or derived from WebPart class)

2. Create a public method in the provider web part decorated with the ConnectionProvider attribute and which returns the value the consumer web part will receive, like the example below.

public partial class Provider : System.Web.UI.UserControl
  string _textBoxValue = "";
  [ConnectionProvider("TextBox provider", "GetTextBoxValue")]
  string GetTextBoxValue()
    return _textBoxValue;
  protected void Button1_Click(object sender, EventArgs e)
    _textBoxValue = TextBoxProvider.Text;

3. Create a consumer web part (either a user control, or derived from WebPart class)

4. Create a public method decorated with the ConnectionConsumer attribute, and that accepts the same data type that the provider's ConnectionProvider method returns, like the following example.

public partial class Consumer : System.Web.UI.UserControl
  [ConnectionConsumer("TextBox consumer", "ShowTextBoxValue")]
  void ShowTextBoxValue(string textBoxValue)
    LabelConsumer.Text = textBoxValue;

5. Create a web page with a WebPartManager and at least one WebPartZone container.

6. Add the provider and consumer web parts to the WebPartZone container(s).

7. Add the asp:WebPartConnection to the StaticConnections section of your WebPartManager control. The WebPartConnection should have the following properties set. Note that you should have one WebPartConnection control for each pair of connected controls.

IDUnique identifier
ProviderIDID of the provider control
ProviderConnectionPointIDName of the provider method
ConsumerIDID of the consumer control
ConsumerConnectionPointIDName of the consumer method

WebPartConnection Example
<asp:WebPartManager ID="WebPartManager1" runat="server">

Enabling Dynamic Connections

1. Create a page with a provider and consumer connection, as in the previous section.

2. Optionally create a static connection (as in the previous section), which will act as the default connection.

3. Add a ConnectionsZone control to the web page.

4. Add a control to enable the user to enter connect mode.


<asp:WebPartManager runat="server">
  <Personalization Enabled="False" />