PageRenderTime 52ms CodeModel.GetById 13ms app.highlight 31ms RepoModel.GetById 2ms app.codeStats 0ms

/projects/PigeonCms.Core/Helpers/FormsBuilder.cs

http://pigeoncms.googlecode.com/
C# | 804 lines | 645 code | 71 blank | 88 comment | 85 complexity | 59953ab14c50650639688afe7d5edd23 MD5 | raw file
  1using System;
  2using System.Data;
  3using System.Configuration;
  4using System.Web;
  5using System.Web.Security;
  6using System.Web.UI;
  7using System.Web.UI.WebControls;
  8using System.Web.UI.WebControls.WebParts;
  9using System.Web.UI.HtmlControls;
 10using System.Diagnostics;
 11using System.ComponentModel;
 12using System.Collections.Generic;
 13using System.IO;
 14using PigeonCms;
 15using System.Xml;
 16using System.Reflection;
 17using System.Web.Compilation;
 18using FredCK.FCKeditorV2;
 19
 20
 21namespace PigeonCms
 22{
 23    public enum FormFieldTypeEnum
 24    {
 25        Text = 0,
 26        List,
 27        Combo,
 28        Radio,
 29        Check,
 30        Calendar,
 31        Custom,
 32        Spacer,
 33        Hidden,
 34        Error,
 35        Html
 36    }
 37
 38    public class FormFieldOption
 39    {
 40        private string label = "";
 41        private string value = "";
 42
 43        public FormFieldOption(string label, string value)
 44        {
 45            this.label = label;
 46            this.value = value;
 47        }
 48
 49        public string Label
 50        {
 51            [DebuggerStepThrough()]
 52            get { return label; }
 53            [DebuggerStepThrough()]
 54            set { label = value; }
 55        }
 56
 57        public string Value
 58        {
 59            [DebuggerStepThrough()]
 60            get { return this.value; }
 61            [DebuggerStepThrough()]
 62            set { this.value = value; }
 63        }
 64    }
 65
 66    [DebuggerDisplay("Name={name}, DefaultValue={defaultValue}, Type={type}")]
 67    public class FormField
 68    {
 69        string group = "";
 70        string name = "";
 71        string defaultValue = "";
 72        int rows = 0;
 73        int cols = 0;
 74        string labelValue = "";
 75        string description = "";
 76        string cssClass = "";
 77        string cssStyle = "";
 78        List<FormFieldOption> options = new List<FormFieldOption>();
 79        FormFieldTypeEnum type = FormFieldTypeEnum.Text;
 80
 81        public FormField(){}
 82
 83        public string Group
 84        {
 85            [DebuggerStepThrough()]
 86            get { return group; }
 87            [DebuggerStepThrough()]
 88            set { group = value; }
 89        }
 90
 91        public string Name
 92        {
 93            [DebuggerStepThrough()]
 94            get { return name; }
 95            [DebuggerStepThrough()]
 96            set { name = value; }
 97        }
 98
 99        public string DefaultValue
100        {
101            [DebuggerStepThrough()]
102            get { return defaultValue; }
103            [DebuggerStepThrough()]
104            set { defaultValue = value; }
105        }
106
107        public int Rows
108        {
109            [DebuggerStepThrough()]
110            get { return rows; }
111            [DebuggerStepThrough()]
112            set { rows = value; }
113        }
114
115        public int Cols
116        {
117            [DebuggerStepThrough()]
118            get { return cols; }
119            [DebuggerStepThrough()]
120            set { cols = value; }
121        }
122
123        public string LabelValue
124        {
125            [DebuggerStepThrough()]
126            get { return labelValue; }
127            [DebuggerStepThrough()]
128            set { labelValue = value; }
129        }
130
131        public string Description
132        {
133            [DebuggerStepThrough()]
134            get { return description; }
135            [DebuggerStepThrough()]
136            set { description = value; }
137        }
138
139        public string CssClass
140        {
141            [DebuggerStepThrough()]
142            get { return cssClass; }
143            [DebuggerStepThrough()]
144            set { cssClass = value; }
145        }
146
147        public string CssStyle
148        {
149            [DebuggerStepThrough()]
150            get { return cssStyle; }
151            [DebuggerStepThrough()]
152            set { cssStyle = value; }
153        }
154
155        public List<FormFieldOption> Options
156        {
157            [DebuggerStepThrough()]
158            get { return options; }
159            [DebuggerStepThrough()]
160            set { options = value; }
161        }
162
163        public FormFieldTypeEnum Type
164        {
165            [DebuggerStepThrough()]
166            get { return type; }
167            [DebuggerStepThrough()]
168            set { type = value; }
169        }
170    }
171
172    /// <summary>
173    /// static class with methods to help controls rendering, controls reading, etc..
174    /// </summary>
175    public static class FormBuilder
176    {
177        #region public methods
178
179        public static Control RenderControl(FormField field, string currentValue)
180        {
181            return RenderControl(field, currentValue, "");
182        }
183
184        /// <summary>
185        /// render the aspnet control parsing param, to admin module
186        /// </summary>
187        /// <param name="field"></param>
188        /// <param name="currentValue"></param>
189        /// <param name="defaultCssClass"></param>
190        /// <returns></returns>
191        public static Control RenderControl(FormField field, string currentValue, string defaultCssClass)
192        {
193            Control result = null;
194            switch (field.Type)
195            {
196                case FormFieldTypeEnum.Text:
197                    result = (Control)getTextControl(field, currentValue, defaultCssClass);
198                    break;
199                case FormFieldTypeEnum.List:
200                    result = (Control)getHiddenControl(field, currentValue);    //TODO
201                    //result = (Control)getListControl(param, currentValue);
202                    break;
203                case FormFieldTypeEnum.Combo:
204                    result = (Control)getComboControl(field, currentValue, defaultCssClass);
205                    break;
206                case FormFieldTypeEnum.Radio:
207                    result = (Control)getHiddenControl(field, currentValue);    //TODO
208                    break;
209                case FormFieldTypeEnum.Check:
210                    result = (Control)getHiddenControl(field, currentValue);    //TODO
211                    break;
212                case FormFieldTypeEnum.Calendar:
213                    result = (Control)getHiddenControl(field, currentValue);    //TODO
214                    break;
215                case FormFieldTypeEnum.Custom:
216                    result = (Control)getHiddenControl(field, currentValue);    //TODO
217                    break;
218                case FormFieldTypeEnum.Spacer:
219                    result = (Control)getSpacerControl(field, currentValue);
220                    break;
221                case FormFieldTypeEnum.Hidden:
222                    result = (Control)getHiddenControl(field, currentValue);
223                    break;
224                case FormFieldTypeEnum.Error:
225                    result = (Control)getHiddenControl(field, currentValue);    //todo
226                    break;
227                case FormFieldTypeEnum.Html:
228                    result = (Control)getHtmlControl(field, currentValue, defaultCssClass);
229                    break;
230                default:
231                    break;
232            }
233
234            return result;
235        }
236
237        /// <summary>
238        /// render the html controls on panel
239        /// </summary>
240        /// <param name="panel">the container for generated controls</param>
241        /// <param name="currentItem">current Item</param>
242        public static void RenderParamsOnPanel(Panel panel, Item currentItem, List<ResLabel> labelsList)
243        {
244            PigeonCms.ItemType itemType = null;
245            Dictionary<string, string> fieldsValues = new Dictionary<string,string>();
246            PropertyInfo pi = null;
247            Type type = null;
248
249            try
250            {
251                type = BuildManager.GetType(currentItem.ItemTypeName, false);
252                itemType = currentItem.ItemType;
253                foreach (FormField currParam in itemType.Fields)
254                {
255                    object value = null;
256                    string baseClassFieldName = "";
257
258                    pi = type.GetProperty(currParam.Name);    //inerithed class field
259                    if (pi != null)
260                    {
261                        foreach (ItemFieldMapAttribute attr in pi.GetCustomAttributes(typeof(ItemFieldMapAttribute), false))
262                        {
263                            if (attr != null)
264                            {
265                                baseClassFieldName = attr.FieldName.ToString(); //base class mapped field
266                                break;
267                            }
268                        }
269                    }
270                    if (!string.IsNullOrEmpty(baseClassFieldName))
271                    {
272                        pi = type.GetProperty(baseClassFieldName); //base class field
273                        if (pi != null)
274                        {
275                            value = pi.GetValue(currentItem, null);
276                            if (value != null)
277                                fieldsValues.Add(currParam.Name, value.ToString());
278                        }
279                    }
280                }
281                RenderParamsOnPanel(panel, fieldsValues, itemType.Fields, labelsList);
282            }
283            catch (Exception ex)
284            {
285                Tracer.Log("RenderParamsOnPanel(): error loading item fields", TracerItemType.Error, ex);
286            }
287        }
288
289        /// <summary>
290        /// render the html controls on panel
291        /// </summary>
292        /// <param name="panel">the container for generated controls</param>
293        /// <param name="fieldsValues">list of params keys and values</param>
294        /// <param name="fieldsList">fields list for the current item (from xml file)</param>
295        public static void RenderParamsOnPanel(Panel panel, Dictionary<string, string> fieldsValues,
296            List<FormField> fieldsList, List<ResLabel> labelsList)
297        {
298            string currGroup = "not set";  //current param group label
299            HtmlTable tableParams = null;   //render table
300
301            //clear previous params list
302            while (panel.Controls.Count > 0)
303            {
304                panel.Controls.RemoveAt(0);
305            }
306
307            foreach (FormField currParam in fieldsList)
308            {
309                //add a pane foreach different param group
310                if (currParam.Group != currGroup)
311                {
312                    currGroup = currParam.Group;
313                    Literal litGroupName = new Literal();
314                    if (string.IsNullOrEmpty(currParam.Group))
315                    {
316                        //litGroupName.Text = Utility.GetLabel("LblModule");
317                    }
318                    else
319                    {
320
321                        litGroupName.Text = currParam.Group;
322                    }
323                    panel.Controls.Add(litGroupName);
324                    tableParams = createTable(tableParams);
325                    panel.Controls.Add(tableParams);
326                }
327
328                //add params to current pane
329                Control control2Add = null;
330                try
331                {
332                    string currentValue = "";
333                    if (fieldsValues.ContainsKey(currParam.Name))
334                    {
335                        currentValue = fieldsValues[currParam.Name];
336                    }
337                    control2Add = FormBuilder.RenderControl(currParam, currentValue, "adminMediumText");
338                }
339                catch (Exception)
340                { }
341                finally
342                {
343                    if (control2Add == null)
344                    {
345                        Literal litErrorParsing = new Literal();
346                        litErrorParsing.Text = Utility.GetErrorLabel("ParamParsing", "Error parsing [" + currParam.Name + "] param");
347                        control2Add = (Control)litErrorParsing;
348                    }
349                }
350                addTableRow(tableParams, currParam, control2Add, labelsList);
351            }
352        }
353
354        /// <summary>
355        /// Get the string with params value to store in db reading controls inside container
356        /// </summary>
357        /// <param name="moduleParams">list of moduleParam</param>
358        /// <param name="container">the parent control</param>
359        /// <returns>the moduleParams string</returns>
360        public static string GetParamsString(List<FormField> formFieldList, Control container)
361        {
362            string res = "";
363            string currValue = "";
364            foreach (FormField currField in formFieldList)
365            {
366                currValue = "";
367
368                #warning to complete GetModuleParamsString
369                switch (currField.Type)
370                {
371                    case FormFieldTypeEnum.Text:
372                        {
373                            TextBox t1 = new TextBox();
374                            t1 = Utility.FindControlRecursive<TextBox>(container, t1.GetType().Name + currField.Name);
375                            if (t1 != null)
376                            {
377                                currValue = t1.Text;
378                            }
379                        }
380                        break;
381
382                    case FormFieldTypeEnum.Html:
383                        {
384                            FCKeditor t1 = new FCKeditor();
385                            t1 = Utility.FindControlRecursive<FCKeditor>(container, t1.GetType().Name + currField.Name);
386                            if (t1 != null)
387                            {
388                                currValue = t1.Value;
389                            }
390                        }
391                        break;
392
393                    case FormFieldTypeEnum.Combo:
394                        {
395                            DropDownList t1 = new DropDownList();
396                            t1 = Utility.FindControlRecursive<DropDownList>(container, t1.GetType().Name + currField.Name);
397                            if (t1 != null)
398                            {
399                                currValue = t1.SelectedValue;
400                            }
401                        }
402                        break;
403
404                    case FormFieldTypeEnum.Hidden:
405                    case FormFieldTypeEnum.Error:
406                        {
407                            HiddenField t1 = new HiddenField();
408                            t1 = Utility.FindControlRecursive<HiddenField>(container, t1.GetType().Name + currField.Name);
409                            if (t1 != null)
410                            {
411                                currValue = t1.Value;
412                            }
413                        }
414                        break;
415                }
416                if (!string.IsNullOrEmpty(currField.Name))
417                {
418                    res += currField.Name + ":=" + currValue + "|";
419                }
420            }
421            if (res.Length > 1)
422            {
423                if (res[res.Length - 1] == '|')
424                {
425                    res = res.Substring(0, res.Length - 1);
426                }
427            }
428            return res;
429        }
430
431        public static FormField GetFormFieldFromXmlNode(XmlNode nodeParam, XmlNode nodeParams)
432        {
433            FormField item = new FormField();
434            try
435            {
436                item.Type = (FormFieldTypeEnum)Enum.Parse(
437                    typeof(FormFieldTypeEnum),
438                    nodeParam.Attributes["type"].Value, true);
439            }
440            catch (Exception)
441            {
442                item.Type = FormFieldTypeEnum.Error;
443            }
444
445            if (nodeParam.Attributes["name"] != null)
446            {
447                item.Name = nodeParam.Attributes["name"].Value;
448            }
449            if (nodeParam.Attributes["default"] != null)
450            {
451                item.DefaultValue = nodeParam.Attributes["default"].Value;
452            }
453            if (nodeParam.Attributes["rows"] != null)
454            {
455                int value = 0;
456                int.TryParse(nodeParam.Attributes["rows"].Value, out value);
457                item.Rows = value;
458            }
459            if (nodeParam.Attributes["cols"] != null)
460            {
461                int value = 0;
462                int.TryParse(nodeParam.Attributes["cols"].Value, out value);
463                item.Cols = value;
464            }
465            if (nodeParam.Attributes["label"] != null)
466            {
467                item.LabelValue = nodeParam.Attributes["label"].Value;
468            }
469            if (nodeParam.Attributes["description"] != null)
470            {
471                item.Description = nodeParam.Attributes["description"].Value;
472            }
473            if (nodeParam.Attributes["cssStyle"] != null)
474            {
475                item.CssStyle = nodeParam.Attributes["cssStyle"].Value;
476            }
477            if (nodeParam.Attributes["cssClass"] != null)
478            {
479                item.CssClass = nodeParam.Attributes["cssClass"].Value;
480            }
481            if (nodeParams.Attributes["group"] != null)
482            {
483                item.Group = nodeParams.Attributes["group"].Value;
484            }
485
486            //options list
487            XmlNodeList optionsList = nodeParam.SelectNodes("option");
488            foreach (XmlNode nodeOption in optionsList)
489            {
490                string label = "";
491                string value = "";
492                if (nodeOption.Attributes["label"] != null)
493                {
494                    label = nodeOption.Attributes["label"].Value;
495                }
496                if (nodeOption.Attributes["value"] != null)
497                {
498                    value = nodeOption.Attributes["value"].Value;
499                }
500                item.Options.Add(new FormFieldOption(label, value));
501            }
502            //other options from datasource list
503            XmlNodeList dsList = nodeParam.SelectNodes("datasource");
504            foreach (XmlNode ds in dsList)
505            {
506                try
507                {
508                    parseTagDatasource(ds, item);
509                }
510                catch (Exception ex)
511                {
512                    throw new ArgumentException(
513                        "Parsing field " + item.Name + " datasource typename ", ex);
514                }
515            }
516            //other options from enum datasource list
517            XmlNodeList enumList = nodeParam.SelectNodes("enum");
518            foreach (XmlNode ds in enumList)
519            {
520                try
521                {
522                    parseTagEnum(ds, item);
523                }
524                catch (Exception ex)
525                {
526                    throw new ArgumentException(
527                        "Parsing field " + item.Name + " enum typename ", ex);
528                }
529            }
530            return item;
531        }
532
533        #endregion
534
535
536        #region private methods
537
538        private static Literal getSpacerControl(FormField param, string currentValue)
539        {
540            Literal ctrl = new Literal();
541            //ctrl.ID = ctrl.GetType().ToString() + param.Name;
542            if (currentValue == null)
543                ctrl.Text = param.DefaultValue;
544            else
545                ctrl.Text = currentValue;
546            return ctrl;
547        }
548
549        private static TextBox getTextControl(FormField param, string currentValue)
550        {
551            return getTextControl(param, currentValue, "");
552        }
553
554        private static TextBox getTextControl(FormField param, string currentValue, string defaultCssClass)
555        {
556            TextBox ctrl = new TextBox();
557            ctrl.ID = ctrl.GetType().Name + param.Name;
558            ctrl.ToolTip = param.Description;
559            ctrl.Style.Value = param.CssStyle;
560            if (!string.IsNullOrEmpty(param.CssClass))
561                ctrl.CssClass = param.CssClass;
562            else
563                ctrl.CssClass = defaultCssClass;//"adminMediumText";
564            if (string.IsNullOrEmpty(currentValue))
565                ctrl.Text = param.DefaultValue;
566            else
567                ctrl.Text = currentValue;
568            if (param.Rows > 0) //textarea
569            {
570                ctrl.TextMode = TextBoxMode.MultiLine;
571                ctrl.Rows = param.Rows;
572                if (param.Cols > 0) ctrl.Columns = param.Cols;
573
574            }
575            //txt1.MaxLength = 50;
576            //txt1.Width = new Unit(255);
577            return ctrl;
578        }
579
580        private static FCKeditor getHtmlControl(FormField param, string currentValue)
581        {
582            return getHtmlControl(param, currentValue, "");
583        }
584
585        private static FCKeditor getHtmlControl(FormField param, string currentValue, string defaultCssClass)
586        {
587            FCKeditor ctrl = new FCKeditor();
588            ctrl.ID = ctrl.GetType().Name + param.Name;
589            ctrl.ToolbarStartExpanded = false;
590            ctrl.ToolbarSet = "Basic";
591
592            //if (!string.IsNullOrEmpty(param.CssClass))
593            //    ctrl.EditorAreaCSS = param.CssClass;
594            //else
595            //    ctrl.EditorAreaCSS = defaultCssClass;//"adminMediumText";
596
597            if (string.IsNullOrEmpty(currentValue))
598                ctrl.Value = param.DefaultValue;
599            else
600                ctrl.Value = currentValue;
601
602            if (param.Rows > 0)
603                ctrl.Height = new Unit(100 * param.Rows);
604            if (param.Cols > 0)
605                ctrl.Width = new Unit(10 * param.Cols);
606
607            return ctrl;
608        }
609
610        private static DropDownList getComboControl(FormField param, string currentValue)
611        {
612            return getComboControl(param, currentValue, "");
613        }
614
615        private static DropDownList getComboControl(FormField param, string currentValue, string defaultCssClass)
616        {
617            DropDownList ctrl = new DropDownList();
618            ctrl.ID = ctrl.GetType().Name + param.Name;
619            ctrl.ToolTip = param.Description;
620            ctrl.Style.Value = param.CssStyle;
621            if (!string.IsNullOrEmpty(param.CssClass))
622                ctrl.CssClass = param.CssClass;
623            else
624                ctrl.CssClass = defaultCssClass;//"adminMediumText";
625            foreach (FormFieldOption item in param.Options)
626            {
627                ctrl.Items.Add(new ListItem(item.Label, item.Value));
628                if (string.IsNullOrEmpty(currentValue))
629                {
630                    if (ctrl.Items[ctrl.Items.Count - 1].Value == param.DefaultValue)
631                        ctrl.Items[ctrl.Items.Count - 1].Selected = true;
632                }
633                else
634                {
635                    if (ctrl.Items[ctrl.Items.Count - 1].Value == currentValue)
636                        ctrl.Items[ctrl.Items.Count - 1].Selected = true;
637                }
638            }
639            return ctrl;
640        }
641
642        private static HiddenField getHiddenControl(FormField param, string currentValue)
643        {
644            HiddenField ctrl = new HiddenField();
645            ctrl.ID = ctrl.GetType().Name + param.Name;
646            if (string.IsNullOrEmpty(currentValue))
647                ctrl.Value = param.DefaultValue;
648            else
649                ctrl.Value = currentValue;
650            return ctrl;
651        }
652
653        //private static TextBox getListControl(ModuleParam param, string currentValue)
654        //{
655        //    ListBox ctrl = new ListBox();
656        //    ctrl.ID = ctrl.GetType().Name + param.Name;
657        //    ctrl.ToolTip = param.Description;
658        //    ctrl.CssClass = "adminMediumText";
659        //    if (currentValue == null)
660        //        ctrl.Text = param.DefaultValue;
661        //    else
662        //        ctrl.Text = currentValue;
663        //    if (param.Rows > 0) //textarea
664        //    {
665        //        ctrl.TextMode = TextBoxMode.MultiLine;
666        //        ctrl.Rows = param.Rows;
667        //        if (param.Cols > 0) ctrl.Columns = param.Cols;
668
669        //    }
670        //    //txt1.MaxLength = 50;
671        //    //txt1.Width = new Unit(255);
672        //    return ctrl;
673        //}
674
675        /// <summary>
676        /// parse datasource tag
677        /// </summary>
678        /// <param name="nodeDatasource"></param>
679        /// <param name="item"></param>
680        private static void parseTagDatasource(XmlNode nodeDatasource, FormField item)
681        {
682            string selectMethod = "";
683            string selectParams = "";
684            string typeName = "";
685
686            if (nodeDatasource != null)
687            {
688                if (nodeDatasource.Attributes["SelectMethod"] != null)
689                {
690                    selectMethod = nodeDatasource.Attributes["SelectMethod"].Value;
691                }
692                if (nodeDatasource.Attributes["SelectParams"] != null)
693                {
694                    selectParams = nodeDatasource.Attributes["SelectParams"].Value;
695                }
696                if (nodeDatasource.Attributes["TypeName"] != null)
697                {
698                    typeName = nodeDatasource.Attributes["TypeName"].Value;
699                }
700
701                object obj;
702                if (!string.IsNullOrEmpty(selectParams))
703                {
704                    var paramsList = Utility.String2List(selectParams);
705                    object[] parameters = paramsList.ToArray();
706                    //object[] parameters = new object[0];
707                    //parameters[0] = selectParams;
708                    obj = PigeonCms.Reflection.Process(typeName, selectMethod, parameters);
709                }
710                else
711                {
712                    obj = PigeonCms.Reflection.Process(typeName, selectMethod, null);
713                }
714
715                Dictionary<string, string> res = (Dictionary<string, string>)obj;
716                foreach (KeyValuePair<string, string> pair in res)
717                {
718                    item.Options.Add(new FormFieldOption(pair.Value, pair.Key));
719                }
720            }
721        }
722
723
724        /// <summary>
725        /// parse enum datasource tag
726        /// </summary>
727        /// <param name="nodeEnum"></param>
728        /// <param name="item"></param>
729        private static void parseTagEnum(XmlNode nodeEnum, FormField item)
730        {
731            string typeName = "";
732
733            if (nodeEnum != null)
734            {
735                if (nodeEnum.Attributes["TypeName"] != null)
736                {
737                    typeName = nodeEnum.Attributes["TypeName"].Value;
738                }
739
740                var type = BuildManager.GetType(typeName, true);
741                foreach (string name in Enum.GetNames(type))
742                {
743                    int value = (int)Enum.Parse(type, name);
744                    item.Options.Add(new FormFieldOption(name, value.ToString()));
745                }
746            }
747        }
748
749
750        /// <summary>
751        /// create the table that contains the params or views rows
752        /// </summary>
753        /// <param name="tableParams">HtmlTable object</param>
754        /// <returns>HtmlTable with the right format</returns>
755        private static HtmlTable createTable(HtmlTable table)
756        {
757            table = new HtmlTable();
758            table.CellSpacing = 0;
759            table.Attributes["class"] = "adminTable";
760            return table;
761        }
762
763        /// <summary>
764        /// add a row with the label and the control for the current param
765        /// </summary>
766        /// <param name="tableParams">table in which add the row</param>
767        /// <param name="currParam">ModuleParam instance of the param to add</param>
768        /// <param name="control2Add">control to add</param>
769        private static void addTableRow(HtmlTable tableParams, FormField currParam,
770            Control control2Add, List<ResLabel> labelsList)
771        {
772            HtmlTableRow row = new HtmlTableRow();
773            HtmlTableCell cell1 = new HtmlTableCell();
774            HtmlTableCell cell2 = new HtmlTableCell();
775            Literal litParamError = new Literal();
776            Label lblParamLabel = new Label();
777
778            //litParamLabel.Text = "<label for='"+ control2Add.ClientID +"' title='"+ currParam.Description +"'>"+ currParam.LabelValue + "</label>";
779            lblParamLabel.Text = LabelsProvider.GetLocalizedVarFromList(labelsList, currParam.LabelValue); //currParam.LabelValue;
780            lblParamLabel.ToolTip = LabelsProvider.GetLocalizedVarFromList(labelsList, currParam.Description); //currParam.Description;
781            lblParamLabel.AssociatedControlID = control2Add.ClientID;
782
783            cell1.Attributes["class"] = "key";
784            cell1.Controls.Add(lblParamLabel);
785            cell2.Controls.Add(control2Add);
786            if (currParam.Type == FormFieldTypeEnum.Error)
787            {
788                litParamError.Text = Utility.GetLabel("ErrParamParsing", "Error parsing [" + currParam.Name + "] param");
789                cell2.Controls.Add(litParamError);
790                //and add an hidden control
791            }
792            if (currParam.Type == FormFieldTypeEnum.Hidden)
793            {
794                //if hidden param hide row
795                row.Style["display"] = "none";
796            }
797            row.Cells.Add(cell1);
798            row.Cells.Add(cell2);
799            tableParams.Rows.Add(row);
800        }
801
802        #endregion
803    }
804}