Example #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>"));
 }
Example #2
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);
            }
        }
		public RepeatInfo()
		{
			outerTableImp   = false;
			repeatColumns   = 0;
			repeatDirection = RepeatDirection.Vertical;
			repeatLayout    = RepeatLayout.Table;
		}
Example #4
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>"));
 }
Example #5
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());
        }
Example #6
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);
        }
		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 ();
		}
Example #8
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();
        }
		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);
		}
Example #10
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;
 }
Example #12
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 ();
		}