Add RadSpell programmatically

3 posts, 1 answers
  1. Stephan
    Stephan avatar
    71 posts
    Member since:
    Jul 2007

    Posted 27 Jan 2009 Link to this post

    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. Answer
    Lini
    Admin
    Lini avatar
    2144 posts

    Posted 30 Jan 2009 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Stephan
    Stephan avatar
    71 posts
    Member since:
    Jul 2007

    Posted 30 Jan 2009 Link to this post

    Hi Lini,

    that did the trick for me.

    thank you so much.
Back to Top