/// <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); }
protected override void Render(HtmlTextWriter writer) { HtmlImage image = new HtmlImage(); image.Border = 0; SetRatingImage(ref image); image.RenderControl(writer); }
/// <summary> /// Renders the contents. /// </summary> /// <param name="output">The output.</param> protected override void RenderContents(HtmlTextWriter output) { using (HtmlImage image = new HtmlImage()) { if (DocumentMediaId == 0) { image.Src = ResolveUrl(placeholderThumbUrl); image.Alt = "No image found"; } else { image.Src = Support.GetImageFileThumbUrl(DocumentMediaId, IsThumbnail); } image.RenderControl(output); } }
internal static void RenderImageTag(HtmlTextWriter output, IBarCodeSettings settings, string barCodeHandlerUrl) { if (settings.Data != null && settings.Data.Trim().Length > 0) { string errorMessage; var generator = new BarCodeGenerator(settings); if (generator.TestRender(out errorMessage)) { HtmlImage htmlImage = new HtmlImage(); htmlImage.Alt = settings.Data; htmlImage.Src = GetBarCodeHandlerCall(settings, barCodeHandlerUrl); htmlImage.RenderControl(output); } else { output.Write("<span class='barCodeError'>{0}</span>", errorMessage); } } else { output.Write("<span class='barCodeError'>Empty barcode data.</span>"); } }