Glossary Item Box
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
Send comments on this topic.
Documentation version 3.2.0.0.
© 2009 Dart Communications. All rights reserved.