Microsoft Office Online
Sign in to My Office Online (What's this?) | Sign in

 
 
Microsoft Office SharePoint Server (MOSS)
Search
Search
 
Check for updates: (c) Microsoft
Office downloads
 
 
 
Warning: You are viewing this page with an unsupported Web browser. This Web site works best with Microsoft Internet Explorer 6.0 or later, Firefox 1.5, or Netscape Navigator 8.0 or later. Learn more about supported browsers.

Email this linkEmail this link Printer-Friendly VersionPrinter-Friendly Version Bookmark and ShareShare
Form Web Part
 

You can use the Form Web Part to connect to and filter a column of data in another Web Part. Both Web Parts must be installed on a server running Microsoft Windows SharePoint Services.

In this article


How you can use the Form Web Part

The Form Web Part makes it easy to filter the contents of List View Web Parts. The Form Web Part sends filter criteria to the List View Web Part. By typing different criteria in the form, you can filter the list in different ways.

For example, you can filter a list of employees by department by selecting from a drop-down list, or you can filter orders by product line.

You can use text boxes, drop-down lists, check boxes, or option buttons on the Form Web Part. Only one field can be connected to a List View Web Part, but different fields can be connected to different Web Parts at the same time. For example, you can have a Form Web Part with a text box and a set of option buttons. The text box can be connected to one List View Web Part and the option buttons to another. When the user clicks the Go button, both List View Web Parts are filtered according to the information entered on the Form Web Part.

Top of Page Top of Page

Connect the Form Web Part to another Web Part

To use the Form Web Part, you connect it with another Web Part that is capable of receiving filtering parameters through a Web Part connection, such as the List View Web Part. The list you want to filter, and the column on which you want to filter it, must be visible in a Web Part on the same page as the Form Web Part. You can connect the Form Web Part to one or more Web Parts on the Web Part Page.

  1. On the Web Part page that contains the Web Part you want to filter, click the Site Actions menu Site Actions menu, and then click Edit Page.
  2. Choose the Web Part zone where you want to place the Form Web Part, and click Add a Web Part.
  3. In the Add Web Parts dialog box, select the Form Web Part, and then click Add.
    The Form Web Part appears with a text box and a Go button.
  4. Form Web Part text field and Go button
  5. Click the arrow next to Edit Web Part Edit Menu, point to Connections, point to Provide Form Value To, and then click the name of the Web Part to which you want to link.
  6. In the Configure Connection dialog box, the Column field should contain T1. Click Next.
  7. The Column field in the Configuration Connection dialog box now shows all of the available columns in the list to which you are providing the filter parameter. Select the field that matches the information from the Form Web Part.

    Connecting Web Parts

  8.  Note   The fields do not have to have the same names, nor do they have to be the same data types. The values sent from the Form Web Part are text values.

  9. Click Finish, then click Exit Edit Mode at the top of the page.

To use the configured Form Web Part, you can type text in the text box and then click Go or press ENTER. The other Web Part will display data that matches the text you typed. To clear the text box so that you can type new text, select the current text, and then delete it. To redisplay all items in the filtered list, click All Items on the View menu.

Top of Page Top of Page

Customize the Form Web Part

You can customize the Form Web Part by using either the Source Editor custom property or a Web design program that is compatible with Windows SharePoint Services, such as Microsoft Office SharePoint Designer 2007.

Instead of the standard text box, you can use option buttons, check boxes, multi-line text boxes, and list boxes. You can assign a default value to the form element, which can be overridden by the user. After you customize the Form Web Part, you can create another instance of it and add it to a Web Part gallery on your site.

If you customize the Form Web Part, keep in mind the following important points:

  • Only one Go button (which uses the HTML INPUT element) can be used to pass data to the other Web Part.
  • The Form Web Part uses the HTML FORM element. Certain HTML elements cannot be used inside the FORM element, including the HTML element, the BODY element, and the HTML FORM element.
  • All form field names must be unique. Each name value is used to connect to a corresponding column name in the Web Part that you are connecting to.
  • Although you can have more than one element (text box, check boxes, etc.) on your form, only one can be connected to the list to be filtered. However, each element can be connected to a different Web Part, so you can filter more than one list at a time, or multiple instances of the same list in different ways.

To customize the Form Web Part, use the Source Editor to add HTML source code to the form content.

Top of Page Top of Page

Use the Source Editor to customize the Form Web Part

  1. On the Web Part page that contains the Web Part you want to filter, click the Site Actions menu , and then click Edit Page.
  2. Choose the Web Part zone where you want to place the Form Web Part, and click Add a Web Part.
  3. In the Add Web Parts dialog box, select the Form Web Part, and then click Add. The Form Web Part appears with a text box and a Go button.
  4. Click the arrow next to Edit, then click Modify Shared Web Part.
  5. On the tool pane, click the Source Editor button.The Text Entry dialog box opens with standard HTML code.
  6. Form Web Part code

  7. To make the code easier to read and modify, insert carriage returns in the text to break the lines as shown here:
  8. Form Web Part code expanded for clarity

The line highlighted in the illustration is the HTML code that produces the text box in the Form Web Part:

<input type="text" name="T1"/>.

You can change this line, but do not change any of the other HTML code in the dialog box.

The Form Web Part dynamically creates a scripting routine at run time to create the connection to the other Web Part. Do not modify the onkeydown or onclick event code in the Source Editor, or you may unintentionally break the Form Web Part.

You can change the name of a field, add labels to form fields, or specify a default value for the text or text area field in the Form Web Part.

To do this: Do this
Change the name of a field

The name of the default text box in the Form Web Part is “T1.” This is the name that appears in the Configuration Connection dialog box. To give the field a more meaningful name, type a new name in place of T1. Do not remove the quotation marks.

Add a label to the form field

You can add label text before or after the form field. Type the text without quotations marks or other symbols. For example, to add the label “Departure Date” before the text field, change the line of code as follows:

Departure Date: <input type="text" name="Date"/>

Add a default value

If you add a default value for the Form Web Part text or text area field, the user can accept the value by clicking the Go button, or override it by typing their own entry.

To add a default value, add “value=” and the default value to the line of code. For example, to add a default value of “Tuesday” to the default text box, change the line of code as follows:

Departure Day: <input type="text" name="Day" value="Tuesday"/>

 Note   If you add a default value, the connected list is filtered by the default value as it is opened, before the user has an opportunity to enter a different value. If the user enters a different value, the connected list is re-filtered by that value.

Top of Page Top of Page

Use a different type of field

Instead of the standard one-line text box, you can use any of these types of fields:

The following examples show the code you would add to use each of these types of fields:

Top of Page Top of Page

Multi-line text box

The ROWS value specifies the number of lines that are visible in the text field. The COLS value specifies the width of the text area in characters. Thus, this example would produce a text box 5 lines deep by 30 characters wide. When the user types in the box, the text will wrap at 30 characters.

<div onkeydown="javascript:if (event.keyCode == 13) _SFSUBMIT_"> 
 	
<textarea name="Description" ROWS=5 COLS=30> 
 	
<input type="button" value="Go" 
onclick="javascript:_SFSUBMIT_"/>
</div>

Top of Page Top of Page

Check box

This example adds a check box with a label. Notice that while the name of the check box is text, the value sent to the connected Web Part is a number. The value can be any type of data. You must specify a value to be sent if the box is checked.

<div onkeydown="javascript:if (event.keyCode == 13) _SFSUBMIT_"> 
 	
Check if you walk to work <input type="checkbox" name="commute" value="1" />
 	
<input type="button" value="Go" 
onclick="javascript:_SFSUBMIT_"/> 
</div>

Top of Page Top of Page

Option Buttons

This examples adds two radio buttons. Both must have the same name. Notice that the labels follow the buttons. The "<br/>" tag causes the buttons to be displayed one on top the other.

<div onkeydown="javascript:if (event.keyCode == 13) _SFSUBMIT_"> 
 	
<input type="radio" name="Date" value="4/1/2009" /> 4/1/2009
<br />
<input type="radio" name="Date" value="4/5/2009" /> 4/5/2009
 	
<input type="button" value="Go" 
onclick="javascript:_SFSUBMIT_"/>
</div>

Top of Page Top of Page

Drop-down list of choices

This code creates a drop-down list. The <select> and </select> tags create the drop-down list box. Each option appears as a separate choice in the list. Only one choice can be selected. The text before the </option> tab (e.g., Walk to work) is what appears in the drop-down list.

<div onkeydown="javascript:if (event.keyCode == 13) _SFSUBMIT_"> 
 	
<select>
 <option value="Walk">Walk to work</option>
 <option value="Bike">Ride my bike</option>
 <option value="Bus">Take a bus</option>
 <option value="Auto">Drive my car</option>
</select>
 	
<input type="button" value="Go" 
onclick="javascript:_SFSUBMIT_"/>
</div>

Top of Page Top of Page

Common properties of Web Parts

All Web Parts share a common set of properties that control their appearance, layout, and advanced characteristics.

 Note   The common Web Part properties that you see in the tool pane may be different from what is documented in this section for several reasons:

  • To see the Advanced section in the tool pane, you must have appropriate permission.
  • For a specific Web Part, a Web Part developer may have chosen not to display one or more of these common properties or may have chosen to create and display additional properties that are not listed below in the Appearance, Layout, and Advanced sections of the tool pane.
  • Some permission and property settings may disable or hide Web Part properties.

Appearance

Property Description
Title Specifies the title of the Web Part that appears in the Web Part title bar.
Height Specifies the height of the Web Part.
Width Specifies the width of the Web Part.
Chrome State Specifies whether the entire Web Part appears on the page when a user opens the Web Part Page. By default, the chrome state is set to Normal and the entire Web Part appears. Only the title bar appears when the state is set to Minimized.
Chrome Type Specifies whether the title bar and border of the Web Part frame are displayed.

Layout

Property Description
Hidden Specifies whether the Web Part is visible when a user opens the Web Part Page. If the check box is selected, the Web Part is visible only when you are designing the page and has the suffix (Hidden) appended to the title.

You can hide a Web Part if you want to use it to provide data to another Web Part through a Web Part connection, but you don't want to display the Web Part.

Direction Specifies the direction of the text in the Web Part content. For example, Arabic is a right-to-left language; English and most other European languages are left-to-right languages. This setting may not be available for all types of Web Parts.
Zone Specifies the zone on the Web Part Page where the Web Part is located.

 Note   Zones on the Web Part Page are not listed in the list box when you do not have permission to modify the zone.

Zone Index Specifies the position of the Web Part in a zone when the zone contains more than one Web Part.

To specify the order, type a positive integer in the text box.

If the Web Parts in the zone are ordered from top to bottom, a value of 1 means that the Web Part appears at the top of the zone. If the Web Parts in the zone are ordered from left to right, a value of 1 means that the Web Part appears on the left of the zone.

For example, when you add a Web Part to an empty zone that is ordered from top to bottom, the Zone Index is 0. When you add a second Web Part to the bottom of the zone, its Zone Index is 1. To move the second Web Part to the top of the zone, type 0, and then type 1 for the first Web Part.

 Note   Each Web Part in the zone must have a unique Zone Index value. Therefore, changing the Zone Index value for the current Web Part can also change the Zone Index value for other Web Parts in the zone.

Advanced

Property Description
Allow Minimize Specifies whether the Web Part can be minimized.
Allow Close Specifies whether the Web Part can be removed from the Web Part Page.
Allow Hide Specifies whether the Web Part can be hidden.
Allow Zone Change Specifies whether the Web Part can be moved to a different zone.
Allow Connections Specifies whether the Web Part can participate in connections with other Web Parts.
Allow Editing in Personal View Specifies whether the Web Part properties can be modified in a personal view.
Export Mode Specifies the level of data that is permitted to be exported for this Web Part. Depending on your configuration, this setting may not be available.
Title URL Specifies the URL of a file containing additional information about the Web Part. The file is displayed in a separate browser window when you click the Web Part title.
Description Specifies the ScreenTip that appears when you rest the mouse pointer on the Web Part title or Web Part icon. The value of this property is used when you search for Web Parts by using the Search command on the Find Web Parts menu of the tool pane in the following Web Part galleries: Site, Virtual Server, and Web Part Page.
Help URL Specifies the location of a file containing Help information about the Web Part. The Help information is displayed in a separate browser window when you click the Help command on the Web Part menu.
Help Mode Specifies how a browser will display Help content for a Web Part.

Select one of the following:

  • Modal Opens a separate browser window, if the browser has this capability. A user must close the window before returning to the Web page.
  • Modeless Opens a separate browser window, if the browser has this capability. A user does not have to close the window before returning to the Web page. This is the default value.
  • Navigate Opens the Web page in the current browser window.

 Note   Even though custom Microsoft ASP.NET Web Parts support this property, default Windows SharePoint Services 3.0 Help topics open only in a separate browser window.

Catalog Icon Image URL Specifies the location of a file containing an image to be used as the Web Part icon in the Web Part List. The image size must be 16 by 16 pixels.
Title Icon Image URL Specifies the location of a file containing an image to be used in the Web Part title bar. The image size must be 16 by 16 pixels.
Import Error Message Specifies a message that appears if there is a problem importing the Web Part.

Top of Page Top of Page

advertisement