How do I convert asp:textbox to freetextbox

678 views Asked by At

I have an asp:TextBox that I need to convert to a FreeTextBox. The following is my asp:TextBox aspx code:

<%@ Register TagPrefix="FTB" Namespace="FreeTextBoxControls" Assembly="FreeTextBox" %>

<asp:TextBox ID="tbxRiskDesc" runat="server" Width="90%" TextMode="MultiLine" Rows="6" onblur="Resize(this);" onkeypress="Resize(this);" ></asp:TextBox>

<rad:RadSpell ID="spellRiskDesc" runat="server" Width="5px" ControlToCheck="tbxRiskDesc" WordIgnoreOptions="UPPERCASE" FragmentIgnoreOptions="EmailAddresses,Urls" DictionaryLanguage="en-AU" SupportedLanguages="en-AU,English" AllowAddCustom="true" DictionaryPath="~/RadControls/Spell/TDF/" SpellCheckProvider="EditDistanceProvider" EditDistance="2" ButtonType="ImageButton" />

The following code is in the aspx.cs code:

Page_Load:

tbxRiskDesc.Attributes.Add("onchange", "setDirty();");

Reset_Data:

SetTextCurrentValue(tbxRiskDesc, dtEditTable, "RiskDesc");

Clear_Data:

SetTextValue(tbxRiskDesc, "RISK TITLE & DESC.:");

When I replace the "asp:TextBox" code in the aspx file with the following, the code behind has errors and i dont know how to change the code for the FreeTextBox for the Page_Load, Reset_Data & Clear_Data sections.

<FTB:FreeTextBox ID="tbxRiskDesc" runat="server"></FTB:FreeTextBox>

The reason for the change over is because we need to allow the users to put bullet points and hyperlinks into the text boxes.

All help is appreciated.

1

There are 1 answers

0
Rumen Jekov On

You have two options:

  • recommended: replace the textbox with RadEditor which has built-in integration with RadSpell
  • use the RadSpell API to spellcheck the FreeTextBox control: You have to get a reference to the body element of the iframe content area of FreeTextBox. After that you can implement a custom text source similarly as it is done for RadEditor in the following forum thread: Problem with spellcheck.

Using the RadEditor's get_contentAreaElement() method you can get a reference to RadEditor's iframe content area element and after that to get a reference to the body tag of the iframe:

var editorSource = $find('RadEditor1').get_contentAreaElement().contentWindow.document.body;

You should see in the FreeTextBox documentation or forums how to get a reference to the body element and update the above line in the provided in the forum article custom text source code.