Displaying Web Part Help


When you create True Web Parts, you have the option of adding a help menu option to the Web Part. You can set two properties related to help:

  • HelpUrl The URL of the help page to display.

  • HelpMode The user interface used when displaying the help page. Possible values are Modal, Modeless, and Navigate.

If you set HelpMode to the value Modal, then the help page opens in a modal window that you must close before returning to the original Web Part page. This option works only with Internet Explorer because it uses the Microsoft proprietary ShowModalDialog() statement.

The Web Part in Listing 28.30 displays a modal help page (see Figure 28.9).

Figure 28.9. Displaying Help for a Web Part.


Listing 28.30. App_Code\ConfusingPart.vb

Imports System Imports System.Web.UI Imports System.Web.UI.WebControls.WebParts Namespace myControls     ''' <summary>     ''' This Web Part illustrates how to     ''' use the HelpUrl and HelpMode properties     ''' </summary>     Public Class ConfusingPart         Inherits WebPart         Private _title As String = "Confusing Part"         Private _helpUrl As String = "~/ConfusingPartHelp.aspx"         Private _helpMode As WebPartHelpMode = WebPartHelpMode.Modal         Public Overrides Property Title() As String             Get                 Return _title             End Get             Set(ByVal Value As String)                 _title = value             End Set         End Property         Public Overrides Property HelpUrl() As String             Get                 Return _helpUrl             End Get             Set(ByVal Value As String)                 _helpUrl = value             End Set         End Property         Public Overrides Property HelpMode() As WebPartHelpMode             Get                 Return _helpMode             End Get             Set(ByVal Value As WebPartHelpMode)                 _helpMode = value             End Set         End Property         Protected Overrides Sub RenderContents(ByVal writer As HtmlTextWriter)             writer.RenderBeginTag(HtmlTextWriterTag.H1)             writer.Write("This Web Part is confusing")             writer.RenderEndTag()             writer.Write("Select the Help menu option for help")         End Sub     End Class End Namespace

Notice that the Web Part in Listing 28.30 overrides both the HelpUrl and HelpMode properties.

Note

You can't use the HelpUrl and HelpMode properties with a Generic Web Part. However, you can simulate the same user experience by adding a custom Help verb, which opens a new browser window, to the Generic Web Part.





ASP. NET 2.0 Unleashed
ASP.NET 2.0 Unleashed
ISBN: 0672328232
EAN: 2147483647
Year: 2006
Pages: 276

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net