Glossary Item Box

PowerWEB TextBox for ASP.NET

Creating a Custom DropDown

While PowerWEB TextBox for ASP.NET includes a default set of pre-configured Toolbar items (enumerated by the ToolbarItemType enumeration) it also allows easy creation of custom drop down boxes. When creating custom drop downs, there are two choices, which are addressed in this topic:

 

Create a custom dropdown for inserting text

If you create a ToolbarDropDown with Type = ToolbarDropDownType.Insert, the initialized ToolbarDropDown comes pre-configured for inserting text values, as the example below illustrates.

[C#]
// Be sure to add "Using Dart.PowerWEB.TextBox" to the top of your code-behind class.

private void Page_Load(object sender, System.EventArgs e)
{
   // Check if it is the first page request. State will be maintained for additional postbacks.
   if(!Page.IsPostBack)
   {
      // Create a custom dropdown for inserting text
      ToolbarDropDown d = new ToolbarDropDown(ToolbarDropDownType.Insert);
      
      // Add some items to be inserted
      d.Items.Add(new ToolbarDropDownItem("Greeting", "To whom it may concern,<br>"));
      d.Items.Add(new ToolbarDropDownItem("Signature", "Best Regards,<br>"));
      d.Items.Add(new ToolbarDropDownItem("Date", DateTime.Now.ToShortDateString()));
      
      // Add the dropdown to the toolbar
      HtmlBox1.Toolbar.Items.Add(d);
   }
}

[Visual Basic]
' Be sure to add "Imports Dart.PowerWEB.TextBox" to the top of your code-behind class.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

   ' Check if it is the first page request. The toolbar will maintain its state for additional postbacks.
   If Not Page.IsPostBack Then
      ' Create a custom dropdown for inserting text
      Dim d As New ToolbarDropDown(ToolbarDropDownType.Insert)
      
      ' Add some items to be inserted
      d.Items.Add(New ToolbarDropDownItem("Greeting", "To whom it may concern,<br>"))
      d.Items.Add(New ToolbarDropDownItem("Signature", "Best Regards,<br>"))
      d.Items.Add(New ToolbarDropDownItem("Date", DateTime.Now.ToShortDateString()))
      
      ' Add the dropdown to the toolbar
      HtmlBox1.Toolbar.Items.Add(d)
   End If
End Sub

 

 

Create a custom dropdown of your own implementation

If you need a more general custom drop down, create a ToolbarDropDown with ToolbarDropDown.Type = ToolbarDropDownType.Custom. This will enable you to configure a drop down that can call any JavaScript function.

[C#]
// Be sure to add "Using Dart.PowerWEB.TextBox" to the top of your code-behind class.

private void Page_Load(object sender, System.EventArgs e)
{
   // Check if it is the first page request. State will be maintained for additional postbacks.
   if(!Page.IsPostBack)
   {
      // Create a custom dropdown for inserting text
      ToolbarDropDown d = new ToolbarDropDown(ToolbarDropDownType.Custom);
      
      // Add some items
      d.Items.Add(new ToolbarDropDownItem("Alert 1", "alert1", "alert('you clicked alert 1')"));
      d.Items.Add(new ToolbarDropDownItem("Alert 2", "alert2", "alert('you clicked alert 2')"));
      d.Items.Add(new ToolbarDropDownItem("Alert 3", "alert3", "alert('you clicked alert 3')"));
      
      // Add the dropdown to the toolbar
          HtmlBox1.Toolbar.Items.Add(d);
   }
}

[Visual Basic]
' Be sure to add "Imports Dart.PowerWEB.TextBox" to the top of your code-behind class.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

   ' Check if it is the first page request. The toolbar will maintain its state for additional postbacks.
   If Not Page.IsPostBack Then
        
      ' Create a custom dropdown for inserting text
      Dim d As New ToolbarDropDown(ToolbarDropDownType.Custom)
      
      ' Add some items
      d.Items.Add(New ToolbarDropDownItem("Alert 1", "alert1", "alert(""you clicked alert 1"")"))
      d.Items.Add(New ToolbarDropDownItem("Alert 2", "alert2", "alert(""you clicked alert 2"")"))
      d.Items.Add(New ToolbarDropDownItem("Alert 3", "alert3", "alert(""you clicked alert 3"")"))
      
      ' Add the dropdown to the toolbar
          HtmlBox1.Toolbar.Items.Add(d)
   
   End If
End Sub

In This Section

Using HtmlBox Skins
Describes how skins can be applied to enhance the HtmlBox and how to create your own skins.
Creating a Custom Button
Describes how to create a custom button to call a JavaScript function.
Creating a Custom Dialog Button
Describes how to create a custom button which launches a dialog when clicked.
Creating a Custom Menu Button
Describes how to create a custom button which opens a menu when clicked.
Creating a Custom DropDown
Describes how to create a custom dropdown box.
Creating a Custom Toolbar Image
Describes how to create a custom toolbar image.
Creating Custom Toolbar Text
Describes how to create custom toolbar text.
Customizing File Uploads
Describes the built in upload support and how it can be customized.
Integrating Spell Checking
Provides steps of how to use a spell checker with the editor.
Integrating with Mail Applications
Provides information on how to integrate the HtmlBox with PowerTCP Mail for .NET to create mail applications which are capable of mailing HTML email messages.

 

 


Send comments on this topic.

Documentation version 3.2.0.0.

© 2009 Dart Communications.  All rights reserved.