public void Render(BocReferenceValueRenderingContext renderingContext)
        {
            ArgumentUtility.CheckNotNull("renderingContext", renderingContext);

            base.Render(renderingContext);

            RegisterInitializationScript(renderingContext);
        }
        private string GetResourcesAsJson(BocReferenceValueRenderingContext renderingContext)
        {
            var resourceManager = GetResourceManager(renderingContext);
            var jsonBuilder     = new StringBuilder(1000);

            jsonBuilder.Append("{ ");
            jsonBuilder.Append("LoadIconFailedErrorMessage : ");
            AppendStringValueOrNullToScript(jsonBuilder, resourceManager.GetString(ResourceIdentifier.LoadIconFailedErrorMessage));
            jsonBuilder.Append(" }");

            return(jsonBuilder.ToString());
        }
        private void RegisterInitializationScript(BocReferenceValueRenderingContext renderingContext)
        {
            if (renderingContext.Control.IsReadOnly)
            {
                return;
            }

            if (!renderingContext.Control.Enabled)
            {
                return;
            }

            string key = renderingContext.Control.ClientID + "_InitializationScript";

            var script = new StringBuilder(1000);

            script.Append("$(document).ready( function() { BocReferenceValue.Initialize(");
            script.AppendFormat("$('#{0}'), ", renderingContext.Control.GetValueName());

            if (renderingContext.Control.IsIconEnabled())
            {
                script.AppendFormat("$('#{0} .{1}'), ", renderingContext.Control.ClientID, CssClassCommand);
            }
            else
            {
                script.Append("null, ");
            }

            script.AppendFormat("'{0}', ", renderingContext.Control.NullValueString);
            AppendBooleanValueToScript(script, renderingContext.Control.DropDownListStyle.AutoPostBack ?? false);
            script.Append(", ");
            AppendStringValueOrNullToScript(script, GetIconServicePath(renderingContext));
            script.Append(", ");
            script.Append(GetIconContextAsJson(renderingContext.IconWebServiceContext) ?? "null");
            script.Append(", ");
            script.Append(GetCommandInfoAsJson(renderingContext) ?? "null");
            script.Append(", ");
            script.Append(GetResourcesAsJson(renderingContext));
            script.Append("); } );");

            renderingContext.Control.Page.ClientScript.RegisterStartupScriptBlock(
                renderingContext.Control,
                typeof(IBocReferenceValue),
                key,
                script.ToString());
        }
 protected virtual IResourceManager GetResourceManager(BocReferenceValueRenderingContext renderingContext)
 {
     return(GetResourceManager(typeof(ResourceIdentifier), renderingContext.Control.GetResourceManager()));
 }