Пример #1
0
        /// <summary>
        /// Load Js Client Scripts
        /// </summary>
        /// <param name="page"></param>
        /// <param name="jsClientScriptsFile"></param>
        /// <param name="jsClientScripts"></param>
        /// <param name="jsClientSideVariables"></param>
        public static void LoadJsClientScripts(Page page, Dictionary <string, string> jsClientScriptsFile, Dictionary <string, string> jsClientScripts, Dictionary <string, string> jsClientSideVariables)
        {
            StringBuilder jsScript = new StringBuilder();

            HtmlGenericControl scriptControl = new HtmlGenericControl("script");

            scriptControl.Attributes.Add("type", "text/javascript");

            // Add JS Variables
            string jsVars = JavaScriptHelper.BuildJsClientSideVariables(jsClientSideVariables);

            jsScript.Append(jsVars);

            // Add JS Scripts
            foreach (KeyValuePair <string, string> script in jsClientScripts)
            {
                jsScript.Append(script.Value);
            }

            // Load to Browser
            scriptControl.InnerHtml = jsScript.ToString();
            page.Header.Controls.Add(scriptControl);

            foreach (KeyValuePair <string, string> jsFile in jsClientScriptsFile)
            {
                scriptControl = new HtmlGenericControl("script");
                scriptControl.Attributes.Add("type", "text/javascript");
                scriptControl.Attributes.Add("src", page.Request.ApplicationPath + jsFile.Value);
                page.Header.Controls.Add(scriptControl);
            }

            JavaScriptHelper.ClearLists();
        }
Пример #2
0
        /// <summary>
        /// Generate the method
        /// </summary>
        /// <returns></returns>
        public string GenerateCode()
        {
            StringBuilder completeMethod   = new StringBuilder();
            string        parameters       = _methodParameters.BuildSeparatedList(", ");
            string        methodDefinition = string.Format(_methodDefinition, _methodName, parameters);

            JavaScriptHelper.AppendLineToBuilderWithSpaces(completeMethod, methodDefinition);
            JavaScriptHelper.AppendLineToBuilderWithSpaces(completeMethod, "{");
            JavaScriptHelper.AppendLineToBuilderWithSpaces(completeMethod, _body.ToString());
            JavaScriptHelper.AppendLineToBuilderWithSpaces(completeMethod, "}");

            return(completeMethod.ToString());
        }
Пример #3
0
        /// <summary>
        /// Generate the code of the block
        /// </summary>
        /// <returns></returns>
        public string GenerateCode()
        {
            StringBuilder completeSection = new StringBuilder();



            JavaScriptHelper.AppendLineToBuilderWithSpaces(completeSection, StartTag);

            foreach (JavaScriptMethod method in Methods)
            {
                JavaScriptHelper.AppendLineToBuilderWithSpaces(completeSection, method.GenerateCode());
            }

            JavaScriptHelper.AppendLineToBuilderWithSpaces(completeSection, EndTag);

            return(completeSection.ToString());
        }
Пример #4
0
 /// <summary>
 /// Add a line of code
 /// </summary>
 /// <param name="line"></param>
 public void AddCode(string line)
 {
     JavaScriptHelper.AppendLineToBuilderWithSpaces(_body, line);
 }