Thursday, 17 January 2013

Creating a Spell Checker with the native Sharepoint 2010 web services

I was checking the other day different ways to create a spell checker for a nice web part I was doing in Sharepoint 2010. I have been trying jQuery spell checkers, but to be honest, they all look quite clunky, in fact most of them work outside Sharepoint but as soon as you try to use them in your webpart, become unstable. If fact, a couple of them work “sometimes” what is the last thing you want when you have to deliver a project to a client.

I heard about Sharepoint Spell Checker, so I start doing some research, I have found a couple of posts on Internet, but they didn’t work either, the closest one comes from “Cherry Bytes” (thanks for sharing the info) and it was for MOSS 2007, so I tried to make it work.

It is pretty simple anyway. The final solution will be a nice pop up box suggesting the spelling (see below):

image

Follow my five steps and in less than 2 minutes, you will have it done!

Step 1
Add the following line on the top of the page:

<%@ Register TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> 


Step 2
Add this line after all the “Registers”… almost top of the page:

<script type="text/javascript" language="javascript" src="/_layouts/1033/form.js"></script>
<script type="text/javascript" language="javascript" src="/_layouts/1033/core.js"></script>
<script type="text/javascript" language="javascript" src="/_layouts/1033/bform.js"></script>
<script type="text/javascript" language="javascript" src="/_layouts/1033/SpellCheckEntirePage.js"></script>


Step 3
Add the JavaScript call to display the form and check the fields:

<script language="javascript" type="text/javascript">
function doSpellCheck() {
    SpellCheckEntirePage('<%= SPContext.Current.Web.Url %>/_vti_bin/SpellCheck.asmx', '<%= SPContext.Current.Web.Url %>/_layouts/SpellChecker.aspx');
}</script> 


Step 4
Add a button to do the spell checking:

<input type="button" value="Spelling" class="bg-color-orange metro-font" onclick="javascript:doSpellCheck();"/>                            


Step 5
Add two textboxes. The first one will be checked by our spell checker, but the second one will be avoided because of the “excludeFromSpellCheck” set it to true:

<asp:TextBox ID="TextBox2" runat="server" ></asp:TextBox> 
<asp:TextBox ID="TextBox1" runat="server" CssClass="ms-long" excludeFromSpellCheck="true"></asp:TextBox> 


Done!


Conclusion:
Probably this is not the most elegant solution in terms of coding, but if we are using Sharepoint as a platform, it is quite good to use native web services instead of third party solutions…and it looks neat!

5 comments:

Anonymous said...

Beautiful work.
Thanks a lot, saved my time

ninest123 said...

replica watches, louis vuitton, air jordan pas cher, longchamp pas cher, ray ban sunglasses, nike air max, oakley sunglasses, ugg boots, oakley sunglasses, nike free, nike roshe run, louboutin shoes, michael kors, louboutin, longchamp outlet, louis vuitton outlet, polo ralph lauren outlet, longchamp outlet, tiffany jewelry, tiffany and co, jordan shoes, tory burch outlet, ugg boots, air max, louis vuitton, replica watches, nike free, louis vuitton, uggs on sale, sac longchamp, burberry, chanel handbags, oakley sunglasses, polo ralph lauren outlet, louboutin outlet, longchamp, louis vuitton outlet, prada outlet, cheap oakley sunglasses, oakley sunglasses, christian louboutin outlet, louboutin pas cher, ralph lauren pas cher, ray ban sunglasses, kate spade outlet, ray ban sunglasses, nike air max, prada handbags, gucci outlet, nike outlet

ninest123 said...

burberry outlet online, nike air max, coach purses, nike air max, michael kors, timberland, new balance pas cher, true religion jeans, kate spade handbags, nike free run uk, north face, true religion jeans, ralph lauren uk, air force, hollister pas cher, ray ban uk, converse pas cher, lacoste pas cher, michael kors outlet, michael kors outlet, ugg boots, michael kors outlet, michael kors outlet, coach outlet, vans pas cher, hollister, burberry, coach outlet, nike blazer, oakley pas cher, vanessa bruno, mulberry, ugg boots, lululemon, hermes, tn pas cher, ray ban pas cher, sac guess, hogan, true religion jeans, abercrombie and fitch, true religion outlet, michael kors, nike air max, michael kors outlet, replica handbags, michael kors, nike roshe, north face, michael kors

ninest123 said...

longchamp, iphone 5s cases, hollister, ferragamo shoes, herve leger, jimmy choo shoes, giuseppe zanotti, north face outlet, vans shoes, mont blanc, nike huarache, celine handbags, iphone cases, iphone 6s cases, nike trainers, lululemon, louboutin, ralph lauren, iphone 6 cases, babyliss, s5 cases, hollister, north face outlet, nfl jerseys, bottega veneta, soccer shoes, oakley, baseball bats, abercrombie and fitch, ghd, chi flat iron, valentino shoes, beats by dre, asics running shoes, wedding dresses, reebok shoes, timberland boots, ipad cases, mac cosmetics, mcm handbags, nike roshe, nike air max, insanity workout, iphone 6s plus cases, birkin bag, p90x workout, hollister, instyler, iphone 6 plus cases, soccer jerseys, new balance

ninest123 said...

barbour jackets, toms shoes, lancel, supra shoes, juicy couture outlet, moncler, moncler, louis vuitton, thomas sabo, hollister, canada goose uk, canada goose, louis vuitton, doudoune canada goose, converse outlet, canada goose outlet, replica watches, bottes ugg, canada goose outlet, nike air max, gucci, moncler, pandora jewelry, canada goose, karen millen, marc jacobs, converse, moncler, ray ban, wedding dresses, montre pas cher, ugg,ugg australia,ugg italia, moncler, pandora charms, canada goose, moncler, canada goose, ugg,uggs,uggs canada, moncler, vans, swarovski crystal, sac louis vuitton pas cher, pandora jewelry, juicy couture outlet, louis vuitton, louis vuitton, moncler outlet, coach outlet, swarovski, ugg boots uk, links of london, ugg pas cher, pandora charms