public override string GetFieldValueAsText(object value)
        {
            HTML5BookmarkField field = (HTML5BookmarkField)value;

            if (field != null)
            {
                return(field.ToString());
            }
            return(string.Empty);
        }
        protected override void CreateChildControls()
        {
            this.DisableInputFieldLabel = true;
            base.ControlMode            = SPContext.Current.FormContext.FormMode;
            base.CreateChildControls();

            BookmarkField = (HTML5BookmarkField)ItemFieldValue;

            if (BookmarkField == null)
            {
                BookmarkField = new HTML5BookmarkField();
            }

            if (base.ControlMode == SPControlMode.Edit || base.ControlMode == SPControlMode.New)
            {
            }
            else
            {
                if (!Page.ClientScript.IsClientScriptIncludeRegistered("JQuery"))
                {
                    Page.ClientScript.RegisterClientScriptInclude(typeof(HTML5BookmarkControl), "JQuery", "/_layouts/Hemrika/Content/jquery.min.js");
                }

                BookmarkSettings settings = new BookmarkSettings();
                settings.Load();

                if (!Page.ClientScript.IsClientScriptIncludeRegistered("BookMark"))
                {
                    Page.ClientScript.RegisterClientScriptInclude(typeof(HTML5BookmarkControl), "BookMark", "/_layouts/Hemrika/Content/jquery.bookmark.js");
                }

                if (!Page.ClientScript.IsClientScriptIncludeRegistered("BookMarkExt") && settings.UseExtended)
                {
                    Page.ClientScript.RegisterClientScriptInclude(typeof(HTML5BookmarkControl), "BookMarkExt", "/_layouts/Hemrika/Content/jquery.bookmark.ext.js");
                }

                CssRegistration.Register("/_layouts/Hemrika/Content/bookmark.css");

                input_Bookmark = (NumberInput)this.TemplateContainer.FindControl("BookmarkInput");

                if (input_Bookmark != null)
                {
                    input_Bookmark.TextChanged += new EventHandler(input_Bookmark_TextChanged);

                    input_Bookmark.Value = BookmarkField.Bookmarks;
                    input_Bookmark.Text  = BookmarkField.Bookmarks.ToString();


                    HtmlGenericControl Bookmark = new HtmlGenericControl("div");
                    Bookmark.Attributes.Add("class", "hasBookmark");
                    Bookmark.ID = "selectBookmark";
                    this.Controls.Add(Bookmark);

                    if (!Page.ClientScript.IsClientScriptBlockRegistered(Bookmark.ClientID))
                    {
                        StringBuilder script = new StringBuilder();
                        script.Append("$(function () {");
                        script.Append("$(\"" + Bookmark.ClientID + "\").bookmark({");
                        //script.Append("onSelect: customBookmark");

                        if (settings.UseCommon)
                        {
                            script.Append("Sites: $.bookmark.commonSites");
                        }
                        else
                        {
                            if (settings.Sites != null && settings.Sites.Count > 0)
                            {
                                script.Append("Sites:[");

                                foreach (string site in settings.Sites)
                                {
                                    script.Append("'" + site + "',");
                                }
                                script.Append("]");
                                script = script.Replace(",]", "]");
                            }
                        }

                        if (settings.AddEmail)
                        {
                            script.Append(",addEmail: true");

                            if (!string.IsNullOrEmpty(settings.EmailSubject))
                            {
                                script.Append(",emailSubject:'" + settings.EmailSubject + "'");
                            }

                            if (!string.IsNullOrEmpty(settings.EmailBody))
                            {
                                script.Append(",emailBody:'" + settings.EmailBody + "'");
                            }
                        }

                        if (settings.AddFavorite)
                        {
                            script.Append(",addFavorite: true");
                        }
                        if (settings.AddAnalytics)
                        {
                            script.Append(",addAnalytics : true");

                            if (!string.IsNullOrEmpty(settings.AnalyticsName))
                            {
                                script.Append(",analyticsName:'" + settings.AnalyticsName + "'");
                            }
                        }

                        script.Append("});");

                        //script = script.Replace("{}","{sites: $.bookmark.commonSites}");
                        script = script.Replace("{}", "");
                        script.Append("});");

                        Page.ClientScript.RegisterClientScriptBlock(typeof(HTML5BookmarkControl), Bookmark.ClientID, script.ToString(), true);
                    }
                }
            }
        }