Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
100
Spell checking multiple controls even on UserControl or Masterpage
posted

I just wanted to share my code that I use to spell check all the controls on one page.  I just drag and drop the spell checking component on the page.  I put on a button in the Click Event to call my javascript function checkspelling.  Thats all I do.  Here is the code:

function checkSpelling() {
    var spellid = GetSpellChecker();
    if (spellid) {
        var len = 1;
        len = spellid.indexOf('_Data');
        spellid = Mid(spellid,0,len);
        var editor = ig_getWebControlById(spellid);
        if (editor == null) {
            alert('Spell Checker Component was not found!');
            return;
        }
        var str = '';
        var elem = document.getElementById('Form1').elements;
        for (var i = 0; i < elem.length; i++) {
            if (elem[i].type == 'text' || elem[i].type == 'textarea') {
                editor.checkTextComponent(elem[i].name);
            }
        }
    }
}

function GetSpellChecker() {
    var str = '';
    var obj;
    var elem = document.getElementById('Form1').elements;
    for (var i = 0; i < elem.length; i++) {
        str = elem[i].name + '';
        if (str.indexOf('_WebSpellChecker') >= 1) {
            return elem[i].name;
        }
    }
    return null;
}