本文整理汇总了C#中System.Web.UI.HtmlControls.HtmlInputText.RenderControl方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlInputText.RenderControl方法的具体用法?C# HtmlInputText.RenderControl怎么用?C# HtmlInputText.RenderControl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.HtmlControls.HtmlInputText
的用法示例。
在下文中一共展示了HtmlInputText.RenderControl方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HoneyPotField
/// <summary>
/// Renders out field with honeypot security check enabled
/// </summary>
/// <param name="helper">HtmlHelper which will be extended</param>
/// <param name="name">Name of field. Should match model field of string type</param>
/// <param name="value">Value of the field</param>
/// <param name="css">CSS class to be applied to input field</param>
/// <returns>Returns render out MvcHtmlString for displaying on the View</returns>
public static MvcHtmlString HoneyPotField(this HtmlHelper helper, string name, object value, string inputCss = null, InputType fieldType=InputType.Text,string honeypotCss = null, InputType honeypotType=InputType.Hidden)
{
StringBuilder sbControlHtml = new StringBuilder();
using (StringWriter stringWriter = new StringWriter())
{
using (HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter))
{
HtmlInputText hashedField = new HtmlInputText(fieldType.ToString().ToLower());
string hashedName = GetHashedPropertyName(name);
hashedField.Value = value != null ? value.ToString() : string.Empty;
hashedField.ID = hashedName;
hashedField.Name = hashedName;
if (!string.IsNullOrWhiteSpace(inputCss))
{
hashedField.Attributes["class"] = inputCss;
}
hashedField.RenderControl(htmlWriter);
HtmlInputText hiddenField = new HtmlInputText(honeypotType.ToString().ToLower());
hiddenField.Value = string.Empty;
hiddenField.ID = name;
hiddenField.Name = name;
if (!string.IsNullOrWhiteSpace(honeypotCss))
{
hiddenField.Attributes["class"] = honeypotCss;
}
hiddenField.RenderControl(htmlWriter);
sbControlHtml.Append(stringWriter.ToString());
}
}
return new MvcHtmlString(sbControlHtml.ToString());
}
示例2: GenerateProductTypePropertyFields
protected void GenerateProductTypePropertyFields()
{
ProductTypePropertiesLiteral.Text = "";
if (lstProductType.SelectedValue.Trim() != string.Empty)
{
string productTypeBvin = lstProductType.SelectedValue;
List<ProductProperty> props = MTApp.CatalogServices.ProductPropertiesFindForType(productTypeBvin);
StringBuilder sb = new StringBuilder();
int count = 0;
foreach (ProductProperty item in props)
{
count += 1;
StringWriter sw = new StringWriter();
HtmlTextWriter writer = new HtmlTextWriter(sw);
sb.Append("<tr><td class=\"formlabel\">");
sb.Append(item.DisplayName);
sb.Append("</td><td class=\"formfield\">");
if (item.TypeCode == ProductPropertyType.CurrencyField)
{
HtmlInputText input = new HtmlInputText();
input.ID = "ProductTypeProperty" + count.ToString();
if (ProductTypeProperties.Count > (count - 1))
{
if (ProductTypeProperties[count - 1] != null)
{
input.Value = ProductTypeProperties[count - 1];
}
else
{
input.Value = item.DefaultValue;
}
}
else
{
input.Value = item.DefaultValue;
}
input.RenderControl(writer);
writer.Flush();
sb.Append(sw.ToString());
}
else if (item.TypeCode == ProductPropertyType.DateField)
{
HtmlInputText input = new HtmlInputText();
input.ID = "ProductTypeProperty" + count.ToString();
if (ProductTypeProperties.Count > (count - 1))
{
if (ProductTypeProperties[count - 1] != null)
{
input.Value = ProductTypeProperties[count - 1];
}
else
{
input.Value = item.DefaultValue;
}
}
else
{
input.Value = item.DefaultValue;
}
input.RenderControl(writer);
writer.Flush();
sb.Append(sw.ToString());
}
else if (item.TypeCode == ProductPropertyType.HyperLink)
{
HtmlInputText input = new HtmlInputText();
input.ID = "ProductTypeProperty" + count.ToString();
if (ProductTypeProperties.Count > (count - 1))
{
if (ProductTypeProperties[count - 1] != null)
{
input.Value = ProductTypeProperties[count - 1];
}
else
{
input.Value = item.DefaultValue;
}
}
else
{
input.Value = item.DefaultValue;
}
input.RenderControl(writer);
writer.Flush();
sb.Append(sw.ToString());
}
else if (item.TypeCode == ProductPropertyType.MultipleChoiceField)
{
HtmlSelect input = new HtmlSelect();
input.ID = "ProductTypeProperty" + count.ToString();
bool setWidth = false;
foreach (ProductPropertyChoice choice in item.Choices)
{
if (choice.ChoiceName.Length > 25)
{
setWidth = true;
}
System.Web.UI.WebControls.ListItem li = new System.Web.UI.WebControls.ListItem(choice.ChoiceName, choice.Id.ToString());
input.Items.Add(li);
}
//.........这里部分代码省略.........