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
590
How to spellcheck multiple fields on same page?
posted

I have multiple textboxes that need spelled checked, I placed a WebSpellChecker control on the page for each text box, but when I click the button the dialog flashes a few times, and i only see the text for the last text box being checked....and it disapears....can't fix any errors.

 How can I do this?

 Also, is there a way to know that the spell check has been completed so that I can display a save button only after the spellcheck has been run?

 

 

Parents
  • 55
    posted

    So, how about this approach:

     

    1. when you click your "Check Spelling" button, collect the content of the various textboxes, etc into an xml string that looks like this:

    <ControlsToCheck>

    <IDofControl1>contents of textbox 1</IDofControl1>

    <IDofControl2>contents of textbox 1</IDofControl2>

    ...

    </ControlsToCheck>

     

    2. In your WebSpellChecker, set AllowXML to true.  Then, using the spellchecker object:

    oWebSpellChecker.checkSpelling(xml string from above)

     

    3. In the completion callback, crack the xml using Microsoft.XMLDOM ActiveXObject (see also http://msdn2.microsoft.com/en-us/library/aa468547.aspx), loadXML method.

     

    4. Go through the name/value pairs, and for each one, get the control (i.e., textbox) whose ID is the "name", and set its text to the "value" (i.e., the corrected text).

     

    This allows you to

     

    1. check multiple controls with just one invocation of the spell check dialog

    2. only create one annoying flash if the text was spelled correctly in the first place, instead of one for every control

    3. hit "ignore all" and have it really ignore all, instead of having to do this once per control.

     

    It's a little tricky, but works pretty well.

    -Scott

Reply Children