20 Feb 2013

Auto Spell Check

Category:
  • Software Applications
  • Software Design & Development

Recently, I was asked to implement an auto spell check functionality for a client’s ASP .Net application.

There are third party custom spell checkers available already; however they come with a high price tag. After doing some research and with the guidance from my seniors, I came across the ‘Telerik Rad Spell’. Initially, by looking at the Telerik documentation and live demo, it just looked fairly straight forward to use but in order to get it to work according to our client’s requirements, a lot of changes had to be made.

As mentioned above, the initial usability of the ‘Telerik Rad Spell’ for simple applications is quite straight forward. All you have to do is register the Telerik assembly and add a script manager in your .aspx page as in the following line:

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>

<telerik:RadScriptManager runat="server" ID="RadScriptManager1" />

Once the assembly has been added, you are free to use ‘Telerik Rad Spell’ anywhere on the page as shown in the following example:

<telerik:RadSpell ID="RadSpell1" runat="server" ButtonType="PushButton"ControlsToCheck="txtRadSpell" AllowAddCustom="true" />

 

In the ‘ControlsToCheck’ property you can add as many different controls you like, separated by comma (,) and it will do the job for you. By default it has three dictionaries (de-DE.tdf, en-US.tdf and fr-FR.tdf) and you can select any dictionary you want according to your requirements. If the dictionary you require has not been defined then ‘Rad Spell’ will automatically select the appropriate dictionary according to the system language settings. Apart from the above dictionaries, there are some other custom dictionaries which are created by different users and are available for download on the Telerik Forum (http://www.telerik.com/community/forums.aspx). However if you choose to use a custom dictionary created by someone on the forums, note that Telerik does not take the responsibility of the validity of those dictionaries so use with caution! If you cannot find the dictionary that you need, information explaining how to create your own custom dictionary can also be found on the Telerik forum.

The ‘AllowAddCustom’ property allows you to add new words to the ‘Custom Dictionary’.

Up until this point, everything seems easy and straight forward but what if you want to add a number of dynamic custom dictionaries for multiple different users? This is where things start to get tricky! By default when you add a new word, Telerik creates a custom dictionary for you and automatically adds the new word for you. For example, your default dictionary is ‘en-US’ and when you add a new word, Telerik will create (if not existing otherwise will append the existing) a new .txt file with the name ‘en-US-Custom’ and add your new word in it. This is fine unless you have users across the globe who have different language preferences as any new words added will keep on being added within the new ‘en-US-Custom’ dictionary and all users will be affected by the change.  To overcome this problem, we have given the option of uploading as many dictionaries that users like (.txt files with one word per line). Also, we have given the option of saved dictionary settings on a per user basis. This dictionary settings page loads all the available custom dictionary names in a combo box, which resides in the /App_Data/RadSpell/ folder. Selected dictionary settings are saved into the database against the logged in username. Now, on Page_Load, by setting the ‘CustomDictionarySuffix’ property of ‘Rad Spell’ with the saved dictionary settings from the database, users are able to use their own specific custom dictionary. In future if any of the users want to change to a different custom dictionary, they can save the new settings and will be able to use the new dictionary.

Go Back

Please enter your details and we will aim to call you back the same day.