Fix the spelling mistakes in a RadEditor before submitting its content
How-To
Combine a spell check button with the save button so the user can click Save and go through a spell check. For example, you may want your user to always fix spelling mistakes in sRadEditor before submitting its content.
Solution
The simplest solution is to use the SpellCheckValidator control that informs the user they need to perform a spellcheck:
Alternatively, you can:
- use a RadSpell instance and point it to the control or controls you wish to have checked
- hook to the client click of the button, prevent the postback and start the spellcheck
- use its OnClientCheckFinished event to invoke the postback
<asp:Button Text="save" OnClientClick="checkMe(); return false;" ID="Button1" OnClick="Button1_Click" runat="server" />
<telerik:RadEditor runat="server" ID="re1" RenderMode="Lightweight">
<Content>miztake</Content>
</telerik:RadEditor>
<telerik:RadSpell runat="server" ID="rs1" IsClientID="true" ButtonType="None" OnClientCheckFinished="OnClientCheckFinished" RenderMode="Lightweight" />
<script>
function checkMe() {
$find("<%=rs1.ClientID%>").startSpellCheck();
}
function OnClientCheckFinished() {
__doPostBack("<%=Button1.UniqueID%>", "");
}
</script>
Codebehind
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
rs1.ControlToCheck = re1.ClientID;
}
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Write("processed" + re1.Content);
}
A third option is to do this purely on the client as shown in the Invoke Separate Spell Check for each Textbox and Submit the Form on Success KB article.