Click here to Skip to main content
15,884,353 members
Articles / Web Development / ASP.NET

ToolTip for MVC Web Application

Rate me:
Please Sign up or sign in to vote.
3.86/5 (4 votes)
12 Dec 2011CPOL3 min read 49.7K   1.2K   19  
ToolTip for MVC Web Application using clutip a jquery plugin
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace ToolTipMvc.Models
{
    public class ToolTipMvcModel
    {
      ToolTipMvcModel(){}
      const string FIELD_DESC_DLMTR = "$_$_$";
      static string[] splitParam = new string[] { FIELD_DESC_DLMTR };
      public string Field { get; set; }
      public string Description { get; set; }
      public string Id { get; set; }
      private ToolTipMvcModel(string id) { Id = id; }
      public static ToolTipMvcModel GetToolTip(string toolTipId)
      {
         ToolTipMvcModel item = new ToolTipMvcModel(toolTipId);
         System.Resources.ResourceSet set = ToolTipMvc.TooTipMvcResource.ResourceManager.GetResourceSet(System.Globalization.CultureInfo.CurrentCulture, true, true);
         string strRes = set.GetString(toolTipId);
         bool bfound = false;
         if(!string.IsNullOrEmpty(strRes))
         {
            string[] strData = strRes.Split(splitParam,StringSplitOptions.None);
            if(strData.Length >= 2)
            {
                try
                {
                    item.Field = strData[0].Split(new string[] { "==" }, StringSplitOptions.None).Where(x => string.Compare("field", x.Trim(), true) != 0).First();
                    item.Description = strData[1].Split(new string[] { "==" }, StringSplitOptions.None).Where(x => string.Compare("description", x.Trim(), true) != 0).First();
                    bfound = true;
                }
                catch (Exception) { }
            }
         }
         if (!bfound)
         {
            item.Field = "Error";
            item.Description = "Sorry Tool Tip for the selected year not found!";         
         }
         return item;
      }
      public static List<ToolTipMvcModel> GetToolTip(params string[] toolTipIds)
      {
          List<ToolTipMvcModel> items = new List<ToolTipMvcModel>();
          items.AddRange(toolTipIds.Select(s=>GetToolTip(s)));  
          return items;
      }    
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer MicroLink LLC
United States United States
Started as C++ developer later fell in love with .NET and moved to .NET. I still use Notepad to type in C# console apps. for learning unknown areas. The software business areas I worked are diversified - Gas, Truck Leasing, Telecom, many State and Federal projects.

Comments and Discussions