public void CreateActionJavaScript(string methodName, StringCollection code, StringCollection parameters, string returnReceiver)
 {
     if (string.CompareOrdinal(methodName, "IsFileTypeValid") == 0)
     {
         if (!string.IsNullOrEmpty(returnReceiver))
         {
             code.Add(string.Format(CultureInfo.InvariantCulture, "{0}=({1}.value.split('.').pop().toLowerCase()>=0);\r\n", returnReceiver, WebPageCompilerUtility.JsCodeRef(CodeName)));
         }
     }
     else if (string.CompareOrdinal(methodName, "IsFileSizeValid") == 0)
     {
         if (!string.IsNullOrEmpty(returnReceiver))
         {
             code.Add(string.Format(CultureInfo.InvariantCulture, "{0}={1}.jsData.IsFileSizeValid();\r\n", returnReceiver, WebPageCompilerUtility.JsCodeRef(CodeName)));
         }
     }
     else if (string.CompareOrdinal(methodName, "SetMaxFileSize") == 0)
     {
         code.Add(string.Format(CultureInfo.InvariantCulture, "{0}.jsData.SetMaxFileSize({1});\r\n", WebPageCompilerUtility.JsCodeRef(CodeName), parameters[0]));
     }
     else
     {
         WebPageCompilerUtility.CreateActionJavaScript(WebPageCompilerUtility.JsCodeRef(CodeName), methodName, code, parameters, returnReceiver);
     }
 }
Пример #2
0
 public void CreateActionJavaScript(string methodName, StringCollection code, StringCollection parameters, string returnReceiver)
 {
     if (string.CompareOrdinal(methodName, "ClearFiles") == 0)
     {
         code.Add(string.Format(CultureInfo.InvariantCulture,
                                "document.getElementById('{0}').loader.ClearFiles();\r\n",
                                this.Site.Name));
     }
     else if (string.CompareOrdinal(methodName, "RemoveFile") == 0)
     {
         code.Add(string.Format(CultureInfo.InvariantCulture,
                                "document.getElementById('{0}').loader.RemoveFile({1});\r\n",
                                this.Site.Name, parameters[0]));
     }
     else if (string.CompareOrdinal(methodName, "GetFiles") == 0)
     {
         code.Add(string.Format(CultureInfo.InvariantCulture,
                                "document.getElementById('{0}').loader.GetFiles();\r\n",
                                this.Site.Name));
     }
     else
     {
         WebPageCompilerUtility.CreateActionJavaScript(WebPageCompilerUtility.JsCodeRef(CodeName), methodName, code, parameters, returnReceiver);
     }
 }
Пример #3
0
 public void CreateActionJavaScript(string methodName, StringCollection code, StringCollection parameters, string returnReceiver)
 {
     if (string.CompareOrdinal("AdjustHeight", methodName) == 0)
     {
         code.Add(string.Format(CultureInfo.InvariantCulture,
                                "JsonDataBinding.adjustElementHeight({0});\r\n", WebPageCompilerUtility.JsCodeRef(CodeName)));
         return;
     }
     WebPageCompilerUtility.CreateActionJavaScript(WebPageCompilerUtility.JsCodeRef(CodeName), methodName, code, parameters, returnReceiver);
 }
        public void CreateActionJavaScript(string methodName, StringCollection code, StringCollection parameters, string returnReceiver)
        {
            string nm;

            if (this.Site == null && (string.IsNullOrEmpty(id) || string.CompareOrdinal(id, "''") == 0) && !string.IsNullOrEmpty(_vaname))
            {
                nm = _vaname;
            }
            else
            {
                nm = WebPageCompilerUtility.JsCodeRef(CodeName);
            }
            WebPageCompilerUtility.CreateActionJavaScript(nm, methodName, code, parameters, returnReceiver);
        }
Пример #5
0
 public void CreateActionJavaScript(string methodName, StringCollection code, StringCollection parameters, string returnReceiver)
 {
     if (string.CompareOrdinal(methodName, "getPrimaryKey") == 0)
     {
         if (!string.IsNullOrEmpty(returnReceiver))
         {
             code.Add(string.Format(CultureInfo.InvariantCulture,
                                    "{0}={1}.jsData.getPrimaryKey();\r\n", returnReceiver, this.CodeName));
         }
     }
     else
     {
         WebPageCompilerUtility.CreateActionJavaScript(WebPageCompilerUtility.JsCodeRef(CodeName), methodName, code, parameters, returnReceiver);
     }
 }
 public void CreateActionJavaScript(string methodName, StringCollection code, StringCollection parameters, string returnReceiver)
 {
     if (string.CompareOrdinal(methodName, "AddFileUploader") == 0)
     {
         string fl = Site.Name;
         code.Add(string.Format(CultureInfo.InvariantCulture,
                                "var {0} = document.createElement('input'); {0}.name = '{0}[]'; {0}.type = 'file'; {0}.style.width = '100%';\r\n",
                                fl));
         code.Add(string.Format(CultureInfo.InvariantCulture,
                                "document.getElementById('{0}').appendChild({1});", this.Site.Name, fl));
     }
     else
     {
         WebPageCompilerUtility.CreateActionJavaScript(WebPageCompilerUtility.JsCodeRef(CodeName), methodName, code, parameters, returnReceiver);
     }
 }
Пример #7
0
 public void CreateActionJavaScript(string methodName, StringCollection code, StringCollection parameters, string returnReceiver)
 {
     WebPageCompilerUtility.CreateActionJavaScript(WebPageCompilerUtility.JsCodeRef(CodeName), methodName, code, parameters, returnReceiver);
 }
 public void CreateActionJavaScript(string methodName, StringCollection code, StringCollection parameters, string returnReceiver)
 {
     if (string.CompareOrdinal(methodName, "AddItem") == 0)
     {
         if (parameters == null || parameters.Count == 0)
         {
             throw new WebBuilderException("HtmlListBox is Missing parameters for AddItem");
         }
         string vn = string.Format(CultureInfo.InvariantCulture, "v{0}", ((uint)(Guid.NewGuid().GetHashCode())).ToString("x", CultureInfo.InvariantCulture));
         code.Add(string.Format(CultureInfo.InvariantCulture, "var {0}=document.createElement('option');\r\n", vn));
         code.Add(string.Format(CultureInfo.InvariantCulture, "{0}.text={1};\r\n", vn, parameters[0]));
         if (parameters.Count > 1)
         {
             if (!string.IsNullOrEmpty(parameters[1]))
             {
                 code.Add(string.Format(CultureInfo.InvariantCulture, "{0}.value={1};\r\n", vn, parameters[1]));
             }
         }
         code.Add(string.Format(CultureInfo.InvariantCulture, "{0}.options.add({1});\r\n", CodeName, vn));
     }
     else if (string.CompareOrdinal(methodName, "RemoveItemByValue") == 0)
     {
         if (parameters == null || parameters.Count == 0)
         {
             throw new WebBuilderException("HtmlListBox is Missing parameters for RemoveItemByValue");
         }
         string idx = string.Format(CultureInfo.InvariantCulture, "i{0}", Guid.NewGuid().GetHashCode().ToString("x", CultureInfo.InvariantCulture));
         code.Add(string.Format(CultureInfo.InvariantCulture,
                                "for(var {0}=0;{0}<{1}.options.length;{0}++) {{\r\nif({1}.options[{0}].value == {2}) {{\r\n{1}.remove({0});\r\nbreak;\r\n}}\r\n}}\r\n",
                                idx, CodeName, parameters[0]));
     }
     else if (string.CompareOrdinal(methodName, "RemoveItemByText") == 0)
     {
         if (parameters == null || parameters.Count == 0)
         {
             throw new WebBuilderException("HtmlListBox is Missing parameters for RemoveItemByText");
         }
         string idx = string.Format(CultureInfo.InvariantCulture, "i{0}", Guid.NewGuid().GetHashCode().ToString("x", CultureInfo.InvariantCulture));
         code.Add(string.Format(CultureInfo.InvariantCulture,
                                "for(var {0}=0;{0}<{1}.options.length;{0}++) {{\r\nif({1}.options[{0}].text == {2}) {{\r\n{1}.remove({0});\r\nbreak;\r\n}}\r\n}}\r\n",
                                idx, CodeName, parameters[0]));
     }
     else if (string.CompareOrdinal(methodName, "RemoveItemByIndex") == 0)
     {
         if (parameters == null || parameters.Count == 0)
         {
             throw new WebBuilderException("HtmlListBox is Missing parameters for RemoveItemByIndex");
         }
         code.Add(string.Format(CultureInfo.InvariantCulture,
                                "if({0} >= 0 && {0} < {1}.options.length) {{ {1}.remove({0}); }}\r\n",
                                parameters[0], CodeName));
     }
     else if (string.CompareOrdinal(methodName, "RemoveSelectedItem") == 0)
     {
         code.Add(string.Format(CultureInfo.InvariantCulture,
                                "if({0}.selectedIndex >= 0 && {0}.selectedIndex < {0}.options.length) {{ {0}.remove({0}.selectedIndex); }}\r\n",
                                CodeName));
     }
     else if (!WebPageCompilerUtility.CreateActionJavaScript(WebPageCompilerUtility.JsCodeRef(CodeName), methodName, code, parameters, returnReceiver))
     {
     }
 }