IWebPart.Description Property
Gets or sets a brief phrase that summarizes what a control does, for use in ToolTips and catalogs of WebPart controls.
Assembly: System.Web (in System.Web.dll)
Property Value
Type: System.StringA string that briefly summarizes the control's functionality. The default value is an empty string ("").
The Description property value is typically used as a descriptive string for a control in catalogs that provide lists of WebPart controls, and as a ToolTip in a control's title bar. The content of the property appears in a ToolTip when a user positions the mouse pointer over the title text in a control's title bar.
The following code example demonstrates declarative and programmatic use of the Description property. The complete source code for the example is found in the Example section of the IWebPart class overview.
The first part of the code example shows how the user control implements the Description property.
Public Property Description() As String _ Implements IWebPart.Description Get Dim objTitle As Object = ViewState("Description") If objTitle Is Nothing Then Return String.Empty End If Return CStr(objTitle) End Get Set(ByVal value As String) ViewState("Description") = value End Set End Property
The second part of the code example demonstrates the method in the user control that programmatically sets the value of the Description property when a user selects the appropriate property name from the radio buttons on the page, sets a new value in the text box, and then clicks the Update button.
Security Note
|
|---|
This example has a text box that accepts user input, which is a potential security threat. By default, ASP.NET Web pages validate that user input does not include script or HTML elements. For more information, see Script Exploits Overview. |
' Update the selected IWebPart property value. Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Dim propertyValue As String = Server.HtmlEncode(TextBox3.Text) TextBox3.Text = String.Empty Select Case RadioButtonList1.SelectedValue Case "title" Me.Title = propertyValue Case "description" Me.Description = propertyValue Case "catalogiconimageurl" Me.CatalogIconImageUrl = propertyValue Case "titleiconimageurl" Me.TitleIconImageUrl = propertyValue Case "titleurl" Me.TitleUrl = propertyValue Case Else End Select End Sub 'Button1_Click
The third part of the code example shows how the user control that implements the IWebPart interface is referenced in a WebPartZone control, and how the Description property is set declaratively on the control. Note that you can see the value of this property by positioning your mouse pointer over the title text in the control's title bar, after you have loaded the page in a browser. You can also experiment with changing the property value programmatically at run time by loading the Web page and using the provided user interface (UI) to change the property value.
<%@ page language="VB" %> <%@ register tagprefix="uc1" tagname="AccountUserControlVB" src="AccountUserControlvb.ascx"%> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title> Personalizable User Control with IWebPart Properties </title> </head> <body> <form id="form1" runat="server"> <asp:webpartmanager id="WebPartManager1" runat="server" /> <asp:webpartzone id="zone1" runat="server" headertext="Main" CloseVerb-Enabled="false"> <zonetemplate> <uc1:AccountUserControlVB runat="server" id="accountwebpart" title="Account Form" Description="Account Form with default values." CatalogIconImageUrl="MyCatalogIcon.gif" TitleIconImageUrl="MyTitleIcon.gif" TitleUrl="MyUrl.html"/> </zonetemplate> </asp:webpartzone> </form> </body> </html>
Available since 2.0
