New to Telerik UI for ASP.NET AJAX? Start a free 30-day trial
Spellchecking Dynamic Controls
Scenario
How to add RadSpell dynamically to the page and/or how to spellcheck dynamic controls.
Solution
To spellcheck dynamic controls:
-
Create dynamic instances of both RadSpell and the control you wish to spellcheck.
-
Add both controls to a placeholder control inside your ASPX / ASCX template.
You need to set the ControlToCheck property after you add both controls to the Controls collection of their parent!
ASP.NET
<form id="form2" runat="server">
<asp:ScriptManager ID="Scriptmanager1" runat="server">
</asp:ScriptManager>
<asp:PlaceHolder runat="server" ID="PlaceHolder1" />
</form>
C#
protected void Page_Load(object sender, EventArgs e)
{
TextBox textArea = new TextBox();
textArea.ID = "TextBox1";
PlaceHolder1.Controls.Add(textArea);
RadSpell spellChecker = new RadSpell();
spellChecker.ID = "RadSpell1";
PlaceHolder1.Controls.Add(spellChecker);
spellChecker.ControlToCheck = textArea.ClientID;
}