Beispiel #1
0
 public void PopulateValuesAndErrors(AjaxFormSubmittedValues values)
 {
     foreach (AjaxFormFieldBlock block in FieldBlocks)
     {
         if (values.Blocks.ContainsKey(block.Name))
         {
             foreach (AjaxFormField fld in block)
             {
                 if (fld is AjaxFormStandardField)
                 {
                     if (values.Blocks[block.Name].Fields.ContainsKey(((AjaxFormStandardField)fld).FieldName))
                     {
                         AjaxFormStandardField         f    = (AjaxFormStandardField)fld;
                         AjaxFormSubmittedValues.Field sfld = values.Blocks[block.Name].Fields[f.FieldName];
                         if (sfld.ErrorMessage != null)
                         {
                             f.FieldError = sfld.ErrorMessage;
                         }
                         if (fld is AjaxFormInputField)
                         {
                             ((AjaxFormInputField)fld).SetValue(sfld.Value);
                         }
                     }
                 }
             }
         }
     }
 }
        public void BuildHTML(AjaxFormType formType, StringWriter htmlWriter, StringWriter jsWriter, bool isAltBlock)
        {
            jsWriter.WriteLine(RunScript);
            htmlWriter.Write("<div id=\"{0}\" class=\"{1} {2}\" name=\"{3}\" formpart=\"block\">",
                             BlockID, CssClass, isAltBlock ? "alt2" : "alt1", Name);
            if (Label != null)
            {
                htmlWriter.Write("<div class=\"{0}\">{1}</div>", CssHeadingClass, Label);
            }
            if (formType == AjaxFormType.FormPost)
            {
                htmlWriter.Write("<input type=\"hidden\" name=\"_BlockName\" value=\"{0}\" />", Name);
            }
            string fieldNames = "";

            foreach (AjaxFormField field in this)
            {
                if (formType == AjaxFormType.FormPost && field is AjaxFormStandardField)
                {
                    AjaxFormStandardField f = (AjaxFormStandardField)field;
                    if (fieldNames.Length > 0)
                    {
                        fieldNames += "|";
                    }
                    fieldNames += HttpUtility.HtmlEncode(f.FieldName);
                    if (f.FieldName == "Password1")
                    {
                        fieldNames += "|Password2";
                    }
                }
                htmlWriter.Write(field.FullFieldHTML);
                jsWriter.WriteLine(field.FullFieldJavaScript);
            }
            if (formType == AjaxFormType.FormPost)
            {
                htmlWriter.Write("<input type=\"hidden\" name=\"_FieldNames_{0}\" value=\"{1}\" />", Name, fieldNames);
            }

            htmlWriter.Write("</div>");
        }