本文整理汇总了C#中System.Web.UI.HtmlControls.HtmlImage.RenderControl方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlImage.RenderControl方法的具体用法?C# HtmlImage.RenderControl怎么用?C# HtmlImage.RenderControl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.HtmlControls.HtmlImage
的用法示例。
在下文中一共展示了HtmlImage.RenderControl方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddRequiredValidator
/// <summary>
/// Generates and adds validator for textbox control
/// </summary>
/// <param name="requiredField">TextBox for which RequiredField validator will be added</param>
public void AddRequiredValidator(TextBox requiredField)
{
RequiredFieldValidator validator = new RequiredFieldValidator();
validator.ControlToValidate = requiredField.ID;
validator.EnableClientScript = true;
validator.SetFocusOnError = true;
using (StringWriter stringWriter = new StringWriter())
{
using (HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter))
{
//Generate container div control
HtmlImage imageControl = new HtmlImage();
imageControl.Src = "/Umbraco/Api/Resource/GetEmbededPng?filename=Error.png";
imageControl.Attributes.Add("class", "error-icon");
imageControl.Attributes.Add("title", "This input field is mandatory!");
//Generate HTML string and dispose object
imageControl.RenderControl(htmlWriter);
validator.ErrorMessage = stringWriter.ToString();
imageControl.Dispose();
}
}
validator.Display = ValidatorDisplay.Dynamic;
requiredField.Parent.Controls.AddAt(requiredField.Parent.Controls.IndexOf(requiredField)+1, validator);
}