Пример #1
0
 public McmsWebQuestion(string strId, bool bRequired, string strRequiredText, string strQuestion, string strControlBase, RepeatDirection rdLayout, string[] strResponses)
     : base(strId, "mcms", bRequired, strRequiredText, strQuestion)
 {
     this.m_listBox = new ListBox();
     this.m_checkBoxList = new CheckBoxList();
     this.m_listControl = null;
     if (strControlBase == "checkbox")
     {
         this.m_checkBoxList.RepeatDirection = rdLayout;
         this.m_listControl = this.m_checkBoxList;
     }
     else
     {
         this.m_listBox.SelectionMode = ListSelectionMode.Multiple;
         this.m_listControl = this.m_listBox;
     }
     foreach (string text in strResponses)
     {
         this.m_listControl.Items.Add(new ListItem(text));
     }
     this.m_listControl.ID = "lst_" + strId;
     this.Controls.Add(this.m_listControl);
     if (bRequired)
     {
         ListControlValidator child = new ListControlValidator();
         child.EnableClientScript = false;
         child.Text = strRequiredText;
         child.Display = ValidatorDisplay.Dynamic;
         child.ControlToValidate = this.m_listControl.ID;
         this.Controls.Add(child);
     }
     this.Controls.Add(new LiteralControl("</p>"));
 }
Пример #2
0
 public McssWebQuestion(string strId, bool bRequired, string strRequiredText, string strQuestion, string strControlBase, RepeatDirection rdLayout, string[] strResponses)
     : base(strId, "mcss", bRequired, strRequiredText, strQuestion)
 {
     this.m_radioButtonList = new RadioButtonList();
     this.m_dropDownList = new DropDownList();
     this.m_listControl = null;
     if (strControlBase == "dropdown")
     {
         this.m_listControl = this.m_dropDownList;
     }
     else
     {
         this.m_radioButtonList.RepeatDirection = rdLayout;
         this.m_listControl = this.m_radioButtonList;
     }
     foreach (string text in strResponses)
     {
         this.m_listControl.Items.Add(new ListItem(text));
     }
     this.m_listControl.ID = "lst_" + strId;
     if (bRequired)
     {
         ListControlValidator child = new ListControlValidator();
         child.EnableClientScript = false;
         child.Text = strRequiredText;
         child.Display = ValidatorDisplay.Dynamic;
         child.ControlToValidate = this.m_listControl.ID;
         this.Controls.Add(child);
     }
     this.Controls.Add(this.m_listControl);
     this.Controls.Add(new LiteralControl("</p>"));
 }
Пример #3
0
 /// <include file='doc\RepeatInfo.uex' path='docs/doc[@for="RepeatInfo.RepeatInfo"]/*' />
 /// <devdoc>
 /// <para>Initializes a new instance of the <see cref='System.Web.UI.WebControls.RepeatInfo'/> class. This class is not
 ///    inheritable.</para>
 /// </devdoc>
 public RepeatInfo()
 {
     repeatDirection   = RepeatDirection.Vertical;
     repeatLayout      = RepeatLayout.Table;
     repeatColumns     = 0;
     outerTableImplied = false;
 }
Пример #4
0
        public MultipleSelectControl(MultipleSelect item, RepeatDirection direction)
        {
            this.item = item;

            l = new Label();
            l.Text = item.Title;
            l.CssClass = "label";
            l.AssociatedControlID = item.Name;
            this.Controls.Add(l);

            list = new CheckBoxList();
            list.RepeatDirection = direction;
            list.ID = item.Name;
            list.CssClass = "alternatives";
            list.DataSource = item.GetChildren();
            list.DataTextField = "Title";
            list.DataValueField = "ID";
            list.DataBind();
            this.Controls.Add(list);

            if (item.Required)
            {
                cv = new CustomValidator { Display = ValidatorDisplay.Dynamic, Text = "*" };
                cv.ErrorMessage = item.Title + " is required";
                cv.ServerValidate += (s, a) => a.IsValid = !string.IsNullOrEmpty(AnswerText);
                cv.ValidationGroup = "Form";
                this.Controls.Add(cv);
            }
        }
Пример #5
0
        public static MvcHtmlString CheckBoxList(this HtmlHelper htmlHelper, string name, string codeCategory, object htmlAttributes = null,
                                                 RepeatDirection repeatDirection = RepeatDirection.Horizontal)
        {
            var codes = CodeManager.GetCodes(codeCategory);

            return(ListControlUtil.GenerateHtml(name, codes, repeatDirection, "checkbox", htmlAttributes, null));
        }
Пример #6
0
		public RepeatInfo()
		{
			outerTableImp   = false;
			repeatColumns   = 0;
			repeatDirection = RepeatDirection.Vertical;
			repeatLayout    = RepeatLayout.Table;
		}
Пример #7
0
        public static MvcHtmlString GenerateHtml(string name, Collection<CodeDescription> codes, RepeatDirection repeatDirection, string type, object stateValue)
        {
            TagBuilder table = new TagBuilder("table");
            int i = 0;
            bool isCheckBox = type == "checkbox";
            if (repeatDirection == RepeatDirection.Horizontal)
            {
                TagBuilder tr = new TagBuilder("tr");
                foreach (var code in codes)
                {
                    i++;
                    string id = string.Format("{0}_{1}", name, i);
                    TagBuilder td = new TagBuilder("td");

                    bool isChecked = false;
                    if (isCheckBox)
                    {
                        IEnumerable<string> currentValues = stateValue as IEnumerable<string>;
                        isChecked = (null != currentValues && currentValues.Contains(code.Code));
                    }
                    else
                    {
                        string currentValue = stateValue as string;
                        isChecked = (null != currentValue && code.Code == currentValue);
                    }

                    td.InnerHtml = GenerateRadioHtml(name, id, code.Description, code.Code, isChecked, type);
                    tr.InnerHtml += td.ToString();
                }
                table.InnerHtml = tr.ToString();
            }
            else
            {
                foreach (var code in codes)
                {
                    TagBuilder tr = new TagBuilder("tr");
                    i++;
                    string id = string.Format("{0}_{1}", name, i);
                    TagBuilder td = new TagBuilder("td");

                    bool isChecked = false;
                    if (isCheckBox)
                    {
                        IEnumerable<string> currentValues = stateValue as IEnumerable<string>;
                        isChecked = (null != currentValues && currentValues.Contains(code.Code));
                    }
                    else
                    {
                        string currentValue = stateValue.ToString();
                        isChecked = (null != currentValue && code.Code == currentValue);
                    }

                    td.InnerHtml = GenerateRadioHtml(name, id, code.Description, code.Code, isChecked, type);
                    tr.InnerHtml = td.ToString();
                    table.InnerHtml += tr.ToString();
                }
            }
            return new MvcHtmlString(table.ToString());
        }
Пример #8
0
        /// <summary>
        /// Raises the PreRender event.
        /// </summary>
        /// <param name="e">An EventArgs object that contains the event data.</param>
        protected override void OnPreRender(EventArgs e)
        {
            if (m_InnerList.Count == 0)
            {
                return;
            }

            RepeatDirection direction   = this.RepeatDirection;
            int             Index       = 0;
            bool            orderNumber = ShowOrderNumber;

            HtmlGenericControl ctl = null;

            try
            {
                if (direction == RepeatDirection.Vertical)
                {
                    ctl = new HtmlGenericControl("ol");
                }

                foreach (System.Web.UI.Control link in m_InnerList)
                {
                    if (link.Visible)
                    {
                        if (direction == RepeatDirection.Horizontal)
                        {
                            if (Index > 0)
                            {
                                Controls.Add(new LiteralControl(m_Delimiter));
                            }
                            if (orderNumber)
                            {
                                Controls.Add(new LiteralControl(string.Concat(Index + 1, ".&nbsp;")));
                            }
                            Controls.Add(link);
                        }
                        else if (direction == RepeatDirection.Vertical)
                        {
                            using (HtmlGenericControl li = new HtmlGenericControl("li"))
                            {
                                li.Controls.Add(link);
                                ctl.Controls.Add(li);
                            }
                        }
                    }
                    Index++;
                }
            }
            finally
            {
                if (ctl != null)
                {
                    Controls.Add(ctl);
                    ctl.Dispose();
                }
            }
        }
Пример #9
0
        public SingleSelectControl(SingleSelect question)
        {
            RepeatDirection direction = question.Vertical ? RepeatDirection.Vertical : RepeatDirection.Horizontal;

            switch (question.SelectionType)
            {
            case Items.SingleSelectType.DropDown:
                lc = new DropDownList();
                break;

            case Items.SingleSelectType.ListBox:
                var lb = new ListBox();
                lb.SelectionMode = ListSelectionMode.Single;
                lc = lb;
                break;

            case Items.SingleSelectType.RadioButtons:
                var rbl = new RadioButtonList();
                rbl.RepeatLayout    = RepeatLayout.Flow;
                rbl.RepeatDirection = direction;
                lc = rbl;
                break;
            }

            lc.CssClass = "alternatives";
            if (question.ID > 0)
            {
                lc.ID = "q" + question.ID;
            }
            lc.DataTextField  = "Title";
            lc.DataValueField = "ID";
            lc.DataSource     = question.Children.WhereAccessible();
            lc.DataBind();

            l          = new Label();
            l.CssClass = "label";
            l.Text     = question.Title;
            if (question.ID > 0)
            {
                l.AssociatedControlID = lc.ID;
            }

            Controls.Add(l);
            Controls.Add(lc);

            if (question.Required)
            {
                cv = new CustomValidator {
                    Display = ValidatorDisplay.Dynamic, Text = "*"
                };
                cv.ErrorMessage    = question.Title + " is required";
                cv.ServerValidate += (s, a) => a.IsValid = !string.IsNullOrEmpty(AnswerText);
                cv.ValidationGroup = "Form";
                Controls.Add(cv);
            }
        }
Пример #10
0
 public static MvcHtmlString CheckboxListFieldFor <TModel>(
     this HtmlHelper <TModel> html,
     Expression <Func <TModel, IList <QPCheckedItem> > > expression,
     IEnumerable <QPSelectListItem> list,
     EntityDataListArgs entityDataListArgs,
     Dictionary <string, object> htmlAttributes,
     RepeatDirection repeatDirection = RepeatDirection.Vertical
     ) => MvcHtmlString.Create(string.Format(
                                   html.FieldTemplate(ExpressionHelper.GetExpressionText(expression), GetMetaData(html, expression).DisplayName),
                                   html.QpCheckBoxListFor(expression, list, entityDataListArgs, htmlAttributes, repeatDirection)
                                   ));
Пример #11
0
 public static MvcHtmlString RadioFieldFor <TModel, TValue>(
     this HtmlHelper <TModel> html,
     Expression <Func <TModel, TValue> > expression,
     IEnumerable <QPSelectListItem> list,
     RepeatDirection repeatDirection       = RepeatDirection.Horizontal,
     EntityDataListArgs entityDataListArgs = null,
     ControlOptions options = null
     ) => MvcHtmlString.Create(string.Format(
                                   html.FieldTemplate(ExpressionHelper.GetExpressionText(expression), GetMetaData(html, expression).DisplayName),
                                   html.QpRadioButtonListFor(expression, list, repeatDirection, entityDataListArgs, options)
                                   ));
Пример #12
0
 public static IHtmlContent CheckboxListFieldFor <TModel>(
     this IHtmlHelper <TModel> html,
     Expression <Func <TModel, IList <QPCheckedItem> > > expression,
     IEnumerable <QPSelectListItem> list,
     EntityDataListArgs entityDataListArgs,
     Dictionary <string, object> htmlAttributes,
     RepeatDirection repeatDirection = RepeatDirection.Vertical)
 {
     return(html.FieldTemplate(
                html.QpCheckBoxListFor(expression, list, entityDataListArgs, htmlAttributes, repeatDirection),
                html.ModelExpressionProvider().GetExpressionText(expression),
                GetMetaData(html, expression).DisplayName));
 }
Пример #13
0
        /// <summary>
        /// Create a horizontal or vertical <see cref="System.Web.UI.WebControls.RadioButtonList"/> and add it into <see cref="Adf.Web.UI.BasePanelItem"/>.
        /// </summary>
        /// <param name="label">The display text of the radio button list within <see cref="Adf.Web.UI.BasePanelItem"/>.</param>
        /// <param name="name">Set the identification of <see cref="System.Web.UI.WebControls.RadioButtonList"/>.</param>
        /// <param name="enabled">A value indicating whether the <see cref="System.Web.UI.WebControls.RadioButtonList"/> control is enabled or not.</param>
        /// <param name="direction">Specifies the direction in which items of a list control are displayed.</param>
        /// <returns>A new instance of the <see cref="Adf.Web.UI.RadioButtonListItem"/> class.</returns>
        public static RadioButtonListItem Create(string label, string name, bool enabled, RepeatDirection direction)
        {
            var l = new Label {Text = ResourceManager.GetString(label)};

            var list = new RadioButtonList
                           {
                               ID = prefix + name,
                               Enabled = enabled,
                               RepeatDirection = direction
                           };

            return new RadioButtonListItem(l, list);
        }
Пример #14
0
        string DoTest(int cols, int cnt, RepeatDirection d, RepeatLayout l, bool OuterTableImplied, bool ftr, bool hdr, bool sep)
        {
            HtmlTextWriter htw = GetWriter();
            RepeatInfo     ri  = new RepeatInfo();

            ri.RepeatColumns     = cols;
            ri.RepeatDirection   = d;
            ri.RepeatLayout      = l;
            ri.OuterTableImplied = OuterTableImplied;

            ri.RenderRepeater(htw, new RepeatInfoUser(ftr, hdr, sep, cnt), new TableStyle(), new DataList());
            return(htw.InnerWriter.ToString());
        }
Пример #15
0
        public static MvcHtmlString CheckBoxListFor <TModel, TProperty>(this HtmlHelper <TModel> htmlHelper,
                                                                        Expression <Func <TModel, TProperty> > expression, string codeCategory, object htmlAttributes = null,
                                                                        RepeatDirection repeatDirection = RepeatDirection.Horizontal)
        {
            var           codes    = CodeManager.GetCodes(codeCategory);
            ModelMetadata metadata = ModelMetadata.FromLambdaExpression <TModel, TProperty>(expression,
                                                                                            htmlHelper.ViewData);
            string name = ExpressionHelper.GetExpressionText(expression);
            string fullHtmlFieldName = htmlHelper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(name);

            return(ListControlUtil.GenerateHtml(fullHtmlFieldName, codes, repeatDirection, "checkbox", metadata.Model,
                                                HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes)));
        }
Пример #16
0
 public static IHtmlContent RadioFieldFor <TModel, TValue>(
     this IHtmlHelper <TModel> html,
     Expression <Func <TModel, TValue> > expression,
     IEnumerable <QPSelectListItem> list,
     RepeatDirection repeatDirection       = RepeatDirection.Horizontal,
     EntityDataListArgs entityDataListArgs = null,
     ControlOptions options = null)
 {
     return(html.FieldTemplate(
                html.QpRadioButtonListFor(expression, list, repeatDirection, entityDataListArgs, options),
                html.ModelExpressionProvider().GetExpressionText(expression),
                GetMetaData(html, expression).DisplayName));
 }
		public static string DoTest (int cols, int cnt, RepeatDirection d, RepeatLayout l, bool OuterTableImplied, bool hdr, bool ftr, bool sep)
		{
			HtmlTextWriter htw = GetWriter ();
			RepeatInfo ri = new RepeatInfo ();
			ri.RepeatColumns = cols;
			ri.RepeatDirection = d;
			ri.RepeatLayout = l;
			ri.OuterTableImplied = OuterTableImplied;
			Style s = new Style ();
			if (cols != 3)
				s.CssClass = "mainstyle";

			ri.RenderRepeater (htw, new RepeatInfoUser (hdr, ftr, sep, cnt), s, new DataList ());
			return htw.InnerWriter.ToString ();
		}
Пример #18
0
        public override void DataBind()
        {
            //DataList显示方式
            this.DataList_Course.RepeatDirection = this.RepeatDirection;
            //DataList显示列数
            this.DataList_Course.RepeatColumns = this.RepeatColumns;

            BLL.Tao.CourseModule coursesBll = new BLL.Tao.CourseModule();
            query.PageIndex = this.AspNetPager1.CurrentPageIndex;
            query.PageSize = this.AspNetPager1.PageSize;
            DataTable dt = coursesBll.GetCourseList(query);
            this.AspNetPager1.RecordCount = this.ITotal;
            this.DataList_Course.DataSource = dt;
            this.DataList_Course.DataBind();
        }
Пример #19
0
        public static IHtmlString DateTimeFor <TModel, TProperty>(this HtmlHelper <TModel> htmlHelper,
                                                                  Expression <Func <TModel, TProperty> > expression, object htmlAttributes = null,
                                                                  RepeatDirection repeatDirection = RepeatDirection.Horizontal)
        {
            ModelMetadata metadata = ModelMetadata.FromLambdaExpression(expression,
                                                                        htmlHelper.ViewData);

            string name = ExpressionHelper.GetExpressionText(expression);

            if (name.IsEmpty())
            {
                throw new ArgumentException("Value cannot be null or an empty string.", "name");
            }
            return(BuildInputTag(name, InputType.DateTime, null, htmlAttributes));
        }
Пример #20
0
        /// <summary>
        /// Saves this instance.
        /// </summary>
        public override void Save()
        {
            base.Save();

            this.Options.RelationTypeId = int.Parse(this.relationTypeDropDownList.SelectedValue);
            RepeatDirection repeatDirection;

            if (!RepeatDirection.TryParse(this.repeatDirectionDropDownList.SelectedValue, true, out repeatDirection))
            {
                repeatDirection = RepeatDirection.Vertical;
            }
            this.Options.RepeatDirection = repeatDirection;
            this.Options.MacroAlias      = this.macroDropDownList.SelectedValue;

            this.SaveAsJson(this.Options);
        }
Пример #21
0
        BarCodeComponent getBarCodeComponentFromServer(string barCodeID)
        {
            BarCodeComponent bc = new BarCodeComponent();

            bc                 = new BarCodeComponent();
            bc.BarCodeID       = this.BarCodeID;
            bc.UniqueID        = this.UniqueID;
            bc.BarCodeInfo     = this.BarCodeInfo;
            bc.BarCodeType     = Type.ToString();
            bc.BarCodeWidth    = this.BarCodeWidth;
            bc.BarCodeHeight   = this.BarCodeHeight;
            bc.PositionX       = CenterPoint.X;
            bc.PositionY       = CenterPoint.Y;
            bc.RepeatDirection = RepeatDirection.ToString();
            return(bc);
        }
Пример #22
0
        public string ToXmlString()
        {
            System.Text.StringBuilder xml = new System.Text.StringBuilder();
            xml.Append(@"       <BarCode ");
            xml.Append(@" UniqueID=""" + UniqueID + @"""");
            xml.Append(@" BarCodeID=""" + BarCodeID + @"""");
            xml.Append(@" BarCodeInfo=""" + BarCodeInfo + @"""");
            xml.Append(@" Type=""" + Type.ToString() + @"""");
            xml.Append(@" PositionX=""" + CenterPoint.X + @"""");
            xml.Append(@" PositionY=""" + CenterPoint.Y + @"""");
            xml.Append(@" RepeatDirection=""" + RepeatDirection.ToString() + @"""");
            xml.Append(@" BarCodeWidth=""" + BarCodeWidth.ToString() + @"""");
            xml.Append(@" BarCodeHeight=""" + BarCodeHeight.ToString() + @"""");
            xml.Append(@" ZIndex=""" + ZIndex + @""">");
            xml.Append(Environment.NewLine);
            xml.Append("        </BarCode>");

            return(xml.ToString());
        }
Пример #23
0
        public string ToXmlString()
        {
            var xml = new System.Text.StringBuilder();

            xml.Append(@"       <FlowNode ");
            xml.Append(@" FK_Flow=""" + FK_Flow + @"""");
            xml.Append(@" NodeID=""" + NodeID + @"""");
            xml.Append(@" NodeName=""" + NodeName + @"""");
            xml.Append(@" Type=""" + HisRunModel.ToString() + @"""");
            xml.Append(@" SubFlow=""" + (HisRunModel == FlowNodeType.Ordinary ? SubFlow : @"") + @"""");
            xml.Append(@" PositionX=""" + CenterPoint.X + @"""");
            xml.Append(@" PositionY=""" + CenterPoint.Y + @"""");
            xml.Append(@" RepeatDirection=""" + RepeatDirection.ToString() + @"""");
            xml.Append(@" ZIndex=""" + ZIndex + @""">");

            xml.Append(Environment.NewLine);
            xml.Append("        </FlowNode>");
            return(xml.ToString());
        }
Пример #24
0
		public SingleSelectControl(SingleSelect question, RepeatDirection direction)
		{
			rbl = new RadioButtonList();
			rbl.CssClass = "alternatives";
			rbl.ID = "q" + question.ID;
			rbl.DataTextField = "Title";
			rbl.DataValueField = "ID";
			rbl.DataSource = question.GetChildren();
			rbl.RepeatLayout = RepeatLayout.Flow;
			rbl.RepeatDirection = direction;
			rbl.DataBind();

			l = new Label();
			l.CssClass = "label";
			l.Text = question.Title;
			l.AssociatedControlID = rbl.ID;

			Controls.Add(l);
			Controls.Add(rbl);
		}
Пример #25
0
        public static string DoTest(int cols, int cnt, RepeatDirection d, RepeatLayout l, bool OuterTableImplied, bool hdr, bool ftr, bool sep)
        {
            HtmlTextWriter htw = GetWriter();
            RepeatInfo     ri  = new RepeatInfo();

            ri.RepeatColumns     = cols;
            ri.RepeatDirection   = d;
            ri.RepeatLayout      = l;
            ri.OuterTableImplied = OuterTableImplied;
            // get some variation in if we use style or not
            Style s = new Style();

            if (cols != 3)
            {
                s.CssClass = "mainstyle";
            }

            ri.RenderRepeater(htw, new RepeatInfoUser(hdr, ftr, sep, cnt), s, new DataList());
            return(htw.InnerWriter.ToString());
        }
Пример #26
0
        public SingleSelectControl(SingleSelect question, RepeatDirection direction)
        {
            rbl                 = new RadioButtonList();
            rbl.CssClass        = "alternatives";
            rbl.ID              = "q" + question.ID;
            rbl.DataTextField   = "Title";
            rbl.DataValueField  = "ID";
            rbl.DataSource      = question.GetChildren();
            rbl.RepeatLayout    = RepeatLayout.Flow;
            rbl.RepeatDirection = direction;
            rbl.DataBind();

            l                     = new Label();
            l.CssClass            = "label";
            l.Text                = question.Title;
            l.AssociatedControlID = rbl.ID;

            Controls.Add(l);
            Controls.Add(rbl);
        }
Пример #27
0
    static void BuildTestCode(StringBuilder sb, Exception ex, int cols, int cnt, RepeatDirection d, RepeatLayout l, bool oti, bool hdr, bool ftr, bool sep, string exp, int num)
    {
        if (ex == null)
        {
            sb.Insert(0, "\t[Test]");
        }
        else
        {
            sb.Insert(0, String.Format("\t[ExpectedException (typeof (global::{0}))]", ex.GetType().FullName));
            sb.Insert(0, "\t[Test]\n");
        }

        sb.AppendFormat(@"
		string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest ({0}, {1}, RepeatDirection.{2}, RepeatLayout.{3}, {4}, {5}, {6}, {7});
",
                        cols,
                        cnt,
                        d,
                        l,
                        oti ? "true" : "false",
                        hdr ? "true" : "false",
                        ftr ? "true" : "false",
                        sep ? "true" : "false");
        if (ex == null)
        {
            sb.AppendFormat(@"		string exp = @""{0}"";
		Assert.AreEqual (exp, v, ""#{1}"");
	}}
", exp, num);
        }
        else
        {
            sb.AppendFormat(@"
		// Exception: {0} (""{1}"")
	}}
", ex.GetType().FullName, ex.Message);
        }
    }
Пример #28
0
        public MultipleSelectControl(MultipleSelect item, RepeatDirection direction)
        {
            this.item = item;

            l          = new Label();
            l.Text     = item.Title;
            l.CssClass = "label";
            if (item.ID > 0)
            {
                l.AssociatedControlID = "q" + item.ID;
            }
            this.Controls.Add(l);

            list = new CheckBoxList();
            list.RepeatDirection = direction;
            if (item.ID > 0)
            {
                list.ID = "q" + item.ID;
            }
            list.CssClass       = "alternatives";
            list.DataSource     = item.Children.WhereAccessible();
            list.DataTextField  = "Title";
            list.DataValueField = "ID";
            list.DataBind();
            this.Controls.Add(list);

            if (item.Required)
            {
                cv = new CustomValidator {
                    Display = ValidatorDisplay.Dynamic, Text = "*"
                };
                cv.ErrorMessage    = item.Title + " is required";
                cv.ServerValidate += (s, a) => a.IsValid = !string.IsNullOrEmpty(AnswerText);
                cv.ValidationGroup = "Form";
                this.Controls.Add(cv);
            }
        }
Пример #29
0
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (this.StopProcessing)
        {
            // Do nothing
        }
        else
        {
            // Set properties
            this.BasicDataList.HideControlForZeroRows = this.HideControlForZeroRows;
            this.BasicDataList.DataBindByDefault      = false;
            this.BasicDataList.RepeatColumns          = this.RepeatColumns;
            this.BasicDataList.RepeatDirection        = this.RepeatDirection;
            this.BasicDataList.RepeatLayout           = this.RepeatLayout;
            this.BasicDataList.OnPageChanged         += new EventHandler <EventArgs>(BasicDataList_OnPageChanged);

            EnsureFilterControl();

            if (!String.IsNullOrEmpty(this.ZeroRowsText))
            {
                this.BasicDataList.ZeroRowsText = this.ZeroRowsText;
            }
        }
    }
Пример #30
0
        public static MvcHtmlString CheckBoxListFor <TModel, TProperty>(this HtmlHelper <TModel> htmlHelper, Expression <Func <TModel, TProperty> > expression, string nameSuffix, string codeCategory, string vTenantID, string vTenantFlag, RepeatDirection repeatDirection = RepeatDirection.Horizontal)
        {
            var           codes             = CodeManager.GetCodes(codeCategory, vTenantID, vTenantFlag);
            ModelMetadata metadata          = ModelMetadata.FromLambdaExpression <TModel, TProperty>(expression, htmlHelper.ViewData);
            string        name              = ExpressionHelper.GetExpressionText(expression);
            string        fullHtmlFieldName = htmlHelper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(name) + "_" + nameSuffix;

            return(ListControlUtil.GenerateHtml(fullHtmlFieldName, codes, repeatDirection, "checkbox", metadata.Model));
        }
Пример #31
0
        public static MvcHtmlString CheckBoxList(this HtmlHelper htmlHelper, string name, string codeCategory, string vTenantID, string vTenantFlag, RepeatDirection repeatDirection = RepeatDirection.Horizontal)
        {
            var codes = CodeManager.GetCodes(codeCategory, vTenantID, vTenantFlag);

            return(ListControlUtil.GenerateHtml(name, codes, repeatDirection, "checkbox", null));
        }
        private static void PrintListRows(DataView dataView, bool rowOrdinals, int top, ValueToStringHandler toString, int repeatColumns, RepeatDirection repeatDirection, string delimiter, string[] columnNames)
        {
            string    ordinalColumnName = null;
            DataTable dataTable         = GetTableFromView(dataView, rowOrdinals, top, ref ordinalColumnName);

            PrintListRows(dataTable, dataTable.AsEnumerable(), rowOrdinals, top, toString, repeatColumns, repeatDirection, delimiter, columnNames, ordinalColumnName);
        }
        private static void PrintListRows(DataTable dataTable, IEnumerable <DataRow> dataRows, bool rowOrdinals, int top, ValueToStringHandler toString, int repeatColumns, RepeatDirection repeatDirection, string delimiter, string[] columnNames, string ordinalColumnName = null)
        {
            if (dataTable != null && string.IsNullOrEmpty(dataTable.TableName) == false)
            {
                WriteLine("{0}:", dataTable.TableName);
            }

            if (dataRows.Count() == 0)
            {
                WriteLine("No rows were selected");
                WriteLine();
                return;
            }

            DataColumn[] columns = GetColumns(dataTable, columnNames, ordinalColumnName);
            if (columns.Length == 0)
            {
                WriteLine("No columns were selected");
                WriteLine();
                return;
            }

            if (top > 0)
            {
                dataRows = dataRows.Take(top);
            }

            int columnsLength = columns.Select(c => c.ColumnName.Length).Max();

            int[] lengths = new int[columns.Length];
            foreach (DataRow row in dataRows)
            {
                CalculateLengths(row, columns, lengths, toString);
            }
            int rowsLength = lengths.Max();

            if (rowOrdinals)
            {
                if (dataRows.Count() > 0)
                {
                    if (columnsLength < 7) // "Ordinal".Length
                    {
                        columnsLength = 7;
                    }

                    int maxRowOrdinal = 0;
                    if (string.IsNullOrEmpty(ordinalColumnName))
                    {
                        maxRowOrdinal = dataRows.Select(row => row.Table.Rows.IndexOf(row)).Max();
                    }
                    else
                    {
                        maxRowOrdinal = dataRows.Select(row => (int)row[ordinalColumnName]).Max();
                    }

                    if (maxRowOrdinal > -1)
                    {
                        int rowOrdinalsLength = maxRowOrdinal.ToString().Length;
                        if (rowsLength < rowOrdinalsLength)
                        {
                            rowsLength = rowOrdinalsLength;
                        }
                    }
                }
            }

            if (repeatColumns < 1)
            {
                repeatColumns = 1;
            }

            if (repeatColumns > dataRows.Count())
            {
                repeatColumns = dataRows.Count();
            }

            int lastRowFilledCellsCount = dataRows.Count() % repeatColumns;

            if (lastRowFilledCellsCount == 0)
            {
                lastRowFilledCellsCount = repeatColumns;
            }
            int lastRowEmptyCellsCount = repeatColumns - lastRowFilledCellsCount;
            int rowsCount = (dataRows.Count() / repeatColumns) + (dataRows.Count() % repeatColumns > 0 ? 1 : 0);

            if (delimiter == null)
            {
                delimiter = string.Empty;
            }

            string cellFormat = string.Format(" {{{{0,-{0}}}}}{1}{{{{{{0}},-{2}}}}} {3}", columnsLength, delimiter, rowsLength, Verticl_Bar);
            string horizontal = new String(Horizontal_Bar, columnsLength + delimiter.Length + rowsLength + 2);

            string header    = Top_Left.ToString();
            string separator = Middle_Left.ToString();
            string footer    = Bottom_Left.ToString();
            string format    = Verticl_Bar.ToString();

            int k = 0;

            for (; k < repeatColumns - 1; k++)
            {
                header    += horizontal + Top_Center;
                separator += horizontal + Middle_Center;
                footer    += horizontal + Bottom_Center;
                format    += string.Format(cellFormat, k + 1);
            }

            k = repeatColumns - 1;
            if (k >= 0)
            {
                header    += horizontal + Top_Right;
                separator += horizontal + Middle_Right;
                footer    += horizontal + Bottom_Right;
                format    += string.Format(cellFormat, k + 1);
            }

            string formatPartial = format;

            if (lastRowEmptyCellsCount > 0)
            {
                formatPartial = Verticl_Bar.ToString();
                for (int i = 0; i < lastRowFilledCellsCount; i++)
                {
                    formatPartial += string.Format(cellFormat, i + 1);
                }
                for (int i = 0; i < lastRowEmptyCellsCount; i++)
                {
                    formatPartial += new String(' ', columnsLength + delimiter.Length + rowsLength + 2) + Verticl_Bar;
                }
            }

            object[] objects = new object[repeatColumns + 1];

            if (repeatDirection == RepeatDirection.Horizontal)
            {
                for (int i = 0; i < rowsCount; i++)
                {
                    WriteLine(i == 0 ? header : separator);
                    var rows = dataRows.Skip(i * repeatColumns).Take(repeatColumns);
                    PrintListRow(rows, columns, objects, (i < rowsCount - 1 ? format : formatPartial), rowOrdinals, toString, ordinalColumnName);
                }
            }
            else if (repeatDirection == RepeatDirection.Vertical && lastRowEmptyCellsCount == 0)
            {
                for (int i = 0; i < rowsCount; i++)
                {
                    WriteLine(i == 0 ? header : separator);
                    var rows = dataRows.Where((r, n) => n % rowsCount == i);
                    PrintListRow(rows, columns, objects, (i < rowsCount - 1 ? format : formatPartial), rowOrdinals, toString, ordinalColumnName);
                }
            }
            else if (repeatDirection == RepeatDirection.Vertical && lastRowEmptyCellsCount > 0)
            {
                for (int i = 0; i < rowsCount; i++)
                {
                    WriteLine(i == 0 ? header : separator);
                    var rows = dataRows.Where((r, n) =>
                                              (n < lastRowFilledCellsCount * rowsCount && n % rowsCount == i) ||
                                              (n >= lastRowFilledCellsCount * rowsCount && (n - (lastRowFilledCellsCount * rowsCount)) % (rowsCount - 1) == i)
                                              );
                    PrintListRow(rows, columns, objects, (i < rowsCount - 1 ? format : formatPartial), rowOrdinals, toString, ordinalColumnName);
                }
            }

            WriteLine(footer);

            WriteLine();
        }
 public static void PrintList(this DataRow[] dataRows, bool rowOrdinals = false, int top = 0, ValueToStringHandler toString = null, int repeatColumns = 2, RepeatDirection repeatDirection = RepeatDirection.Vertical, string delimiter = ": ", params string[] columnNames)
 {
     PrintListRows((dataRows.Length != 0 ? dataRows[0].Table : null), dataRows, rowOrdinals, top, toString, repeatColumns, repeatDirection, delimiter, columnNames);
 }
Пример #35
0
		string DoTest (int cols, int cnt, RepeatDirection d, RepeatLayout l, bool OuterTableImplied, bool ftr, bool hdr, bool sep)
		{
			HtmlTextWriter htw = GetWriter ();
			RepeatInfo ri = new RepeatInfo ();
			ri.RepeatColumns = cols;
			ri.RepeatDirection = d;
			ri.RepeatLayout = l;
			ri.OuterTableImplied = OuterTableImplied;

			ri.RenderRepeater (htw, new RepeatInfoUser (ftr, hdr, sep, cnt), new TableStyle (), new DataList ());
			return htw.InnerWriter.ToString ();
		}
Пример #36
0
        public static MvcHtmlString RadioButtonListFor <TModel, TProperty>(this HtmlHelper <TModel> htmlHelper, Expression <Func <TModel, TProperty> > expression, string codeCategory, string direction, RepeatDirection repeatDirection = RepeatDirection.Horizontal, IDictionary <string, object> htmlAttributes = null)
        {
            var           codes      = CodeManager.GetCodes(codeCategory);
            ModelMetadata metadata   = ModelMetadata.FromLambdaExpression <TModel, TProperty>(expression, htmlHelper.ViewData);
            string        name       = ExpressionHelper.GetExpressionText(expression);
            var           attributes = htmlHelper.GetUnobtrusiveValidationAttributes(name, metadata);

            foreach (var item in attributes)
            {
                htmlAttributes.Add(item);
            }
            string fullHtmlFieldName = htmlHelper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(name);
            string stateValue        = (string)metadata.Model;

            return(GenerateHtml(fullHtmlFieldName, codes, direction, repeatDirection, htmlAttributes, stateValue));
        }
Пример #37
0
	static void BuildTestCode (StringBuilder sb, Exception ex, int cols, int cnt, RepeatDirection d, RepeatLayout l, bool oti, bool hdr, bool ftr, bool sep, string exp, int num)
	{
		if (ex == null) {
			sb.Insert (0, "\t[Test]");
		} else {
			sb.Insert (0, String.Format ("\t[ExpectedException (typeof (global::{0}))]", ex.GetType ().FullName));
			sb.Insert (0, "\t[Test]\n");
		}

		sb.AppendFormat (@"
		string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest ({0}, {1}, RepeatDirection.{2}, RepeatLayout.{3}, {4}, {5}, {6}, {7});
",
			cols,
			cnt,
			d,
			l,
			oti ? "true" : "false",
			hdr ? "true" : "false",
			ftr ? "true" : "false",
			sep ? "true" : "false");
		if (ex == null) {
			sb.AppendFormat (@"		string exp = @""{0}"";
		Assert.AreEqual (exp, v, ""#{1}"");
	}}
", exp, num);
		} else {
			sb.AppendFormat (@"
		// Exception: {0} (""{1}"")
	}}
", ex.GetType ().FullName, ex.Message);
		}
	}
 public MultipleSelectControl(MultipleSelect item, RepeatDirection direction)
 {
     this.item = item;
     list = new CheckBoxList();
     list.RepeatDirection = direction;
 }
Пример #39
0
        public static MvcHtmlString RadioButtonList(this HtmlHelper htmlHelper, string name, string codeCategory, string direction, RepeatDirection repeatDirection = RepeatDirection.Horizontal, IDictionary <string, object> htmlAttributes = null)
        {
            var codes = CodeManager.GetCodes(codeCategory);

            return(GenerateHtml(name, codes, direction, repeatDirection, htmlAttributes, null));
        }
 public static void PrintList(this DataSet dataSet, bool rowOrdinals = false, int top = 0, ValueToStringHandler toString = null, int repeatColumns = 2, RepeatDirection repeatDirection = RepeatDirection.Vertical, string delimiter = ": ", params string[] columnNames)
 {
     foreach (DataTable dataTable in dataSet.Tables)
     {
         PrintList(dataTable, rowOrdinals, top, toString, repeatColumns, repeatDirection, delimiter, columnNames);
     }
 }
Пример #41
0
        private static MvcHtmlString GenerateHtml(string name, Collection <CodeDescription> codes, string direction, RepeatDirection repeatDirection, IDictionary <string, object> htmlAttributes, string stateValue = null)
        {
            TagBuilder table = new TagBuilder("table");
            int        i     = 0;

            if (repeatDirection == RepeatDirection.Horizontal)
            {
                TagBuilder tr = new TagBuilder("tr");
                foreach (var code in codes)
                {
                    i++;
                    string     id = string.Format("{0}_{1}", name, i);
                    TagBuilder td = new TagBuilder("td");
                    td.InnerHtml  = GenerateRadioHtml(name, id, code.Description, code.Code, direction, (stateValue != null && stateValue == code.Code), htmlAttributes);
                    tr.InnerHtml += td.ToString();
                }
                table.InnerHtml = tr.ToString();
            }
            else
            {
                foreach (var code in codes)
                {
                    TagBuilder tr = new TagBuilder("tr");
                    i++;
                    string     id = string.Format("{0}_{1}", name, i);
                    TagBuilder td = new TagBuilder("td");
                    td.InnerHtml     = GenerateRadioHtml(name, id, code.Description, code.Code, direction, (stateValue != null && stateValue == code.Code), htmlAttributes);
                    tr.InnerHtml     = td.ToString();
                    table.InnerHtml += tr.ToString();
                }
            }
            return(new MvcHtmlString(table.ToString()));
        }
 public static void PrintList(this DataRow[] dataRows, int repeatColumns, RepeatDirection repeatDirection, params string[] columnNames)
 {
     PrintList(dataRows, false, 0, null, repeatColumns: repeatColumns, repeatDirection: repeatDirection, columnNames: columnNames);
 }