예제 #1
0
		/// <summary>
		/// Outputs a hidden element with an index (for internal use)
		/// </summary>
		/// <param name="index"></param>
		/// <param name="target">The object to get the value from and to be based on to create the element name.</param>
		/// <param name="suffix"></param>
		/// <param name="item"></param>
		/// <param name="attributes">Attributes for the FormHelper method and for the html element it generates</param>
		/// <returns>The generated form element</returns>
		internal string HiddenFieldItem(int index, string target, string suffix, SetItem item, IDictionary attributes)
		{
			target = String.Format("{0}[{1}]", target, index);

			var elementId = CreateHtmlId(attributes, target, true);

			var computedTarget = target;

			return CreateInputElement("hidden", elementId, computedTarget, item.Value, attributes);
		}
예제 #2
0
		/// <summary>
		/// Outputs a checkbox element (for internal use)
		/// </summary>
		/// <param name="index"></param>
		/// <param name="target">The object to get the value from and to be based on to create the element name.</param>
		/// <param name="suffix"></param>
		/// <param name="item"></param>
		/// <param name="attributes">Attributes for the FormHelper method and for the html element it generates</param>
		/// <returns>The generated form element</returns>
		internal string CheckboxItem(int index, string target, string suffix, SetItem item, IDictionary attributes)
		{
			if (item.IsSelected)
			{
				AddChecked(attributes);
			}
			else
			{
				RemoveChecked(attributes);
			}

			target = String.Format("{0}[{1}]", target, index);

			var elementId = CreateHtmlId(attributes, target, true);

			var computedTarget = target;

			if (!string.IsNullOrEmpty(suffix))
			{
				computedTarget += "." + suffix;
			}

			return CreateInputElement("checkbox", elementId, computedTarget, item.Value, attributes);
		}