Home | Blog | Screencasts | Projects
# Thursday, September 25, 2008

I’ve previously posted a demo that made use of a tag suggestion web part, as you type the web part will make an ajax call which will return the tags that match the current input. The user can click on the suggestion tag and it will populate the textbox, multiple tags can be entered into the textbox.

image

 

The most interesting part of this web part is the server side call, which I’ve implemented as a HttpHandler in the Tags.ashx file:

 

public class Handler : IHttpHandler {

    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text";

 

I’ve made use of the System.Web.Extensions JavaScriptSerializer to render the string array of tags to JSON:

   1: List<string> tagList = new List<string>();
   2:  
   3: //add all the tags to a collection, JSON serialize the list
   4:  
   5: System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
   6:  
   7: context.Response.Write(serializer.Serialize(tagList.ToArray()));
   8:  

I’ve put this handler in the /_vti_bin/ directory of SharePoint which maps to the ISAPI folder under the 12 hive.

 

I’ve used the same code to generate the tags as I did with the tag cloud web part, so once again the generation of these tags won’t scale to large lists, this is just an example of how to implement a JQuery based Tag Suggestion web part.

 

The source code for this web part can be found here.

Thursday, September 25, 2008 7:39:59 PM (E. Australia Standard Time, UTC+10:00)  #    Comments [0] - Trackback
code | Sharepoint | Work
Tracked by:
"JQuery Web Parts on CodePlex" (Daniels Blog) [Trackback]
"http://httpcode.com/blogs/PermaLink,guid,773ebf4a-82f9-42de-8fdc-bc1d7c59abe3.a... [Pingback]
Comments are closed.
Statistics
Total Posts: 191
This Year: 0
This Month: 0
This Week: 0
Comments: 41