This is a migrated thread and some comments may be shown as answers.

Add RadSpell programmatically

2 Answers 115 Views
Spell
This is a migrated thread and some comments may be shown as answers.
Stephan
Top achievements
Rank 1
Stephan asked on 27 Jan 2009, 03:05 PM
Hi, i want to add the RadSpell-control programmatically to my page and be able to set it language. Adding the control programmatically is no problem but only when I don't want to change the default language, which is en-US.

when I set it to de-DE or fr-FR (both lib's are in the App_Data-folder), the control is rendered, but when I click the button, nothing happens.

I got this code:
 RadSpell spell = new RadSpell(); 
        spell.ButtonType = Telerik.Web.UI.ButtonType.PushButton; 
        spell.ControlToCheck = tb1.ID; 
        spell.DictionaryLanguage = "fr-fr"
        spell.SupportedLanguages = new string[] { "en-us, English, de-de, German, fr-fr, French" }; 
        spell.DictionaryPath = @"~/App_Data/RadSpell"; 
 
I tried this in onInit and prerender. As said, the spell button is shown, but it only works when I leave out all the lines after dictionarylanguage. Otherwise it shows, but clicking does not trigger anything.

What should I do?

Version: 2008.03.1105.20
Teste both in FF 3 and IE 6


--------------- Edit ---------------------

When I put a RadSpell control on the page and set the properties programmatically, it is also working. However I want to be able to add  the RadSpell control on the page based on some system settings.

 RadSpell spell = (Page.Form.FindControl("clientSpell") as RadSpell); 
        spell.ButtonType = Telerik.Web.UI.ButtonType.PushButton; 
        spell.ControlToCheck = tb1.ID; 
        spell.DictionaryLanguage = "de-DE"
        //spell.SupportedLanguages = new string[] { "en-us, English, de-de, German, fr-fr, French" }; 
        //spell.DictionaryPath = @"~/App_Data/RadSpell"; 
 
        this.form1.Controls.Add(spell); 



2 Answers, 1 is accepted

Sort by
0
Accepted
Lini
Telerik team
answered on 30 Jan 2009, 08:45 AM
Hi Stephan,

I can see two things that are wrong in your definition.

First, try adding an ID property for the RadSpell control:

        RadSpell spell = new RadSpell();
        spell.ID = "RadSpell1";
...

Second, you have not set the SupportedLanguages property correctly. It is a string array, so each value should be a separate string:

        spell.SupportedLanguages = new string[] { "en-us", "English", "de-de", "German", "fr-fr", "French" };

After these changes, your definition should look like this:

RadSpell spell = new RadSpell(); 
spell.ID = "RadSpell1"
spell.ButtonType = Telerik.Web.UI.ButtonType.PushButton; 
spell.ControlToCheck = tb1.ID; 
spell.DictionaryLanguage = "fr-fr"
spell.SupportedLanguages = new string[] { "en-us""English""de-de""German""fr-fr""French" }; 
spell.DictionaryPath = @"~/App_Data/RadSpell"


Kind regards,
Lini
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Stephan
Top achievements
Rank 1
answered on 31 Jan 2009, 03:44 AM
Hi Lini,

that did the trick for me.

thank you so much.
Tags
Spell
Asked by
Stephan
Top achievements
Rank 1
Answers by
Lini
Telerik team
Stephan
Top achievements
Rank 1
Share this question
or