当前位置: 首页>>代码示例>>C#>>正文


C# HtmlInputText.RenderControl方法代码示例

本文整理汇总了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());
        }
开发者ID:dejanstojanovic,项目名称:MVC-Honeypot,代码行数:41,代码来源:HtmlHelpers.cs

示例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);
                        }
//.........这里部分代码省略.........
开发者ID:NightOwl888,项目名称:MerchantTribe,代码行数:101,代码来源:Products_Edit.aspx.cs


注:本文中的System.Web.UI.HtmlControls.HtmlInputText.RenderControl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。