本文整理汇总了C#中System.Web.UI.HtmlTextWriter.WriteEncodedText方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlTextWriter.WriteEncodedText方法的具体用法?C# HtmlTextWriter.WriteEncodedText怎么用?C# HtmlTextWriter.WriteEncodedText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.HtmlTextWriter
的用法示例。
在下文中一共展示了HtmlTextWriter.WriteEncodedText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WithBody
public EmailBuilder WithBody(IEnumerable<KeyValuePair<string, IList>> lists)
{
var writer = new StringWriter();
var html = new HtmlTextWriter(writer);
html.RenderBeginTag(HtmlTextWriterTag.H1);
html.WriteEncodedText(_viewModel.Subject);
html.RenderEndTag();
html.WriteBreak();
html.WriteBreak();
foreach (var list in lists)
{
html.RenderBeginTag(HtmlTextWriterTag.H3);
html.WriteEncodedText(list.Key);
html.RenderEndTag();
html.RenderBeginTag(HtmlTextWriterTag.Ul);
foreach (var item in list.Value)
{
html.RenderBeginTag(HtmlTextWriterTag.Li);
html.WriteEncodedText(item.ToString());
html.RenderEndTag();
}
html.RenderEndTag();
html.WriteBreak();
html.WriteBreak();
}
_viewModel.Body = writer.ToString();
return this;
}
示例2: RenderContents
protected override void RenderContents(HtmlTextWriter writer)
{
writer.AddAttribute("class", "header");
writer.RenderBeginTag(HtmlTextWriterTag.Div);
writer.RenderBeginTag(HtmlTextWriterTag.Label);
writer.Write("Foreach");
writer.RenderEndTag();
writer.AddAttribute("class", "ww-code");
writer.RenderBeginTag(HtmlTextWriterTag.Div);
writer.WriteEncodedText(this.Argument);
writer.RenderEndTag();
writer.RenderBeginTag(HtmlTextWriterTag.Label);
writer.Write("in");
writer.RenderEndTag();
writer.AddAttribute("class", "ww-code");
writer.RenderBeginTag(HtmlTextWriterTag.Div);
writer.WriteEncodedText(this.Values);
writer.RenderEndTag();
writer.RenderEndTag();
writer.RenderBeginTag(HtmlTextWriterTag.Label);
writer.Write("Body");
writer.RenderEndTag();
writer.AddAttribute("class", "body");
writer.RenderBeginTag(HtmlTextWriterTag.Div);
this.Body.Render(writer);
writer.RenderEndTag();
}
示例3: RenderContents
protected override void RenderContents(HtmlTextWriter writer)
{
writer.AddAttribute("class", "ww-code");
writer.RenderBeginTag(HtmlTextWriterTag.Span);
writer.WriteEncodedText(this.To);
writer.RenderEndTag();
writer.WriteEncodedText("=");
writer.AddAttribute("class", "ww-code");
writer.RenderBeginTag(HtmlTextWriterTag.Span);
writer.WriteEncodedText(this.Value);
writer.RenderEndTag();
}
示例4: Render
protected override void Render(HtmlTextWriter writer)
{
var errorMessages = GetErrorMessages().ToArray();
writer.AddAttribute(HtmlTextWriterAttribute.Class, CssClass);
writer.AddAttribute(HtmlTextWriterAttribute.Id, ClientID);
if (!errorMessages.Any()) {
writer.AddAttribute(HtmlTextWriterAttribute.Style, "display: none;");
}
using (writer.RenderTag(HtmlTextWriterTag.Div)) {
if (!String.IsNullOrEmpty(HeaderText)) {
writer.AddAttribute(HtmlTextWriterAttribute.Class, "header");
using (writer.RenderTag(HtmlTextWriterTag.Span)) {
writer.WriteEncodedText(HeaderText);
}
}
if (errorMessages.Any()) {
using (writer.RenderTag(HtmlTextWriterTag.Ul)) {
foreach (var message in errorMessages) {
if (message == null)
continue;
using (writer.RenderTag(HtmlTextWriterTag.Li)) {
writer.Write(message);
}
}
}
}
}
}
示例5: Render
protected override void Render(HtmlTextWriter writer)
{
writer.AddAttribute(HtmlTextWriterAttribute.Id, string.Concat(ClientID, "-container"));
writer.AddAttribute(HtmlTextWriterAttribute.Class, "button");
writer.RenderBeginTag(HtmlTextWriterTag.Span);
if ( NavigateUrl == null )
{
AddAttributesToRender(writer);
}
else
{
string path = NavigateUrl;
string qs = string.Empty;
int splitIndex = path.IndexOf('?');
if ( splitIndex != -1 )
{
path = NavigateUrl.Substring(0, splitIndex);
qs = NavigateUrl.Substring(splitIndex);
}
path = VirtualPathUtility.ToAbsolute(path);
writer.AddAttribute(HtmlTextWriterAttribute.Href, string.Concat(path, qs));
}
writer.RenderBeginTag(HtmlTextWriterTag.A);
writer.WriteEncodedText(Text);
writer.RenderEndTag();
writer.RenderEndTag();
}
示例6: RenderContents
protected override void RenderContents(HtmlTextWriter writer)
{
writer.AddAttribute("class", "header");
writer.RenderBeginTag(HtmlTextWriterTag.Div);
writer.RenderBeginTag(HtmlTextWriterTag.Label);
writer.Write("CorrelatesWith");
writer.RenderEndTag();
writer.AddAttribute("class", "ww-code");
writer.RenderBeginTag(HtmlTextWriterTag.Div);
writer.WriteEncodedText(this.CorrelatesWith ?? string.Empty);
writer.RenderEndTag();
writer.RenderEndTag();
writer.RenderBeginTag(HtmlTextWriterTag.Label);
writer.Write("Body");
writer.RenderEndTag();
writer.AddAttribute("class", "body");
writer.RenderBeginTag(HtmlTextWriterTag.Div);
this.Body.Render(writer);
writer.RenderEndTag();
}
示例7: RadioButton
/// <summary>
/// Renders the RadioButton
/// </summary>
/// <param name="helper">The helper.</param>
/// <param name="displayText">The display text.</param>
/// <param name="radioButtonName">Name of the radio button.</param>
/// <param name="radioButtonValue">The radio button value.</param>
/// <param name="radioButtonId">The radio button id.</param>
/// <param name="radioButtonIsChecked">if set to <c>true</c> [radio button is checked].</param>
/// <param name="radioButtonHtmlAttributes">The radio button HTML attributes.</param>
/// <returns></returns>
public static string RadioButton(this HtmlHelper helper, string displayText, string radioButtonName, object radioButtonValue, string radioButtonId, bool radioButtonIsChecked, IDictionary<string, object> radioButtonHtmlAttributes)
{
var writer = new HtmlTextWriter(new StringWriter());
writer.AddAttribute("for", radioButtonId);
writer.RenderBeginTag(HtmlTextWriterTag.Label);
writer.AddAttribute("type", "radio");
writer.AddAttribute("id", radioButtonId);
writer.AddAttribute("name", radioButtonName);
writer.AddAttribute("value", radioButtonValue.ToString());
if (radioButtonIsChecked)
{
writer.AddAttribute("checked", "checked");
}
foreach (var pair in radioButtonHtmlAttributes)
{
writer.AddAttribute(pair.Key, pair.Value.ToString());
}
writer.RenderBeginTag(HtmlTextWriterTag.Input);
writer.RenderEndTag();
writer.WriteEncodedText(displayText);
writer.RenderEndTag();
return writer.InnerWriter.ToString();
}
示例8: Render
protected override void Render(HtmlTextWriter writer)
{
this.AddAttributes(writer);
writer.AddAttribute(HtmlTextWriterAttribute.Style, "display:none");
writer.RenderBeginTag(HtmlTextWriterTag.Input);
writer.RenderEndTag();
if(!string.IsNullOrWhiteSpace(this.Label))
{
writer.AddAttribute(HtmlTextWriterAttribute.For, this.ID + "_input");
writer.RenderBeginTag(HtmlTextWriterTag.Label);
writer.WriteEncodedText(this.Label);
writer.RenderEndTag();
}
writer.AddAttribute(HtmlTextWriterAttribute.Id, this.ID + "_input");
writer.AddAttribute(HtmlTextWriterAttribute.Name, this.ID + "_input");
writer.AddAttribute(HtmlTextWriterAttribute.Type, "text");
writer.AddAttribute(HtmlTextWriterAttribute.Class, "file");
writer.AddAttribute(HtmlTextWriterAttribute.Value, this.Value);
if(!this.Enabled)
writer.AddAttribute(HtmlTextWriterAttribute.Disabled, "disabled");
writer.RenderBeginTag(HtmlTextWriterTag.Input);
writer.RenderEndTag();
//调用基类同名方法
base.Render(writer);
}
示例9: Render
//***************************************************************************
// Private Methods
//
protected override void Render(HtmlTextWriter writer)
{
base.Render(writer);
if (!this.CheckRender())
return;
writer.AddAttribute(HtmlTextWriterAttribute.Class, string.IsNullOrEmpty(this.CssClass)
? "iconGroup"
: this.CssClass);
writer.RenderBeginTag(HtmlTextWriterTag.Fieldset);
writer.RenderBeginTag(HtmlTextWriterTag.Legend);
writer.WriteEncodedText(this._menuItem.Text);
writer.RenderEndTag(); // Legend
foreach (Control c in this.Controls)
{
if (!(c is DynamicMenuChildControl))
continue;
c.RenderControl(writer);
}
writer.RenderEndTag(); // Fieldset
}
示例10: Write
public HtmlTextWriter Write(HtmlTextWriter writer)
{
if (_escape)
writer.WriteEncodedText(_text);
else
writer.Write(_text);
return writer;
}
示例11: RenderContents
protected internal override void RenderContents(HtmlTextWriter writer)
{
string errorMessage = this.ErrorMessage;
if (!string.IsNullOrEmpty(errorMessage))
{
writer.WriteEncodedText(System.Web.SR.GetString("ErrorWebPart_ErrorText", new object[] { errorMessage }));
}
}
示例12: WriteTextInTag
private static void WriteTextInTag(HtmlTextWriter writer, string tagName, string format, params string[] args)
{
string text = string.Format(format, args);
writer.WriteFullBeginTag(tagName);
writer.WriteEncodedText(text);
writer.WriteEndTag(tagName);
}
示例13: RenderChildren
protected override void RenderChildren(HtmlTextWriter writer)
{
try
{
base.RenderChildren(writer);
}
catch (HttpException ex)
{
writer.WriteFullBeginTag("div");
writer.WriteFullBeginTag("h1");
writer.WriteEncodedText("Error: Control could not be loaded");
writer.WriteEndTag("h1");
writer.WriteFullBeginTag("p");
writer.WriteEncodedText(ex.Message);
writer.WriteEndTag("p");
writer.WriteEndTag("div");
}
}
示例14: RenderDisplayName
private void RenderDisplayName(HtmlTextWriter writer, string displayName, string associatedClientID)
{
if (this.Zone != null)
{
this.Zone.LabelStyle.AddAttributesToRender(writer, this);
}
writer.AddAttribute(HtmlTextWriterAttribute.For, associatedClientID);
writer.RenderBeginTag(HtmlTextWriterTag.Label);
writer.WriteEncodedText(displayName);
writer.RenderEndTag();
}
示例15: RenderContents
protected override void RenderContents(HtmlTextWriter writer)
{
writer.RenderBeginTag(HtmlTextWriterTag.Label);
writer.Write("Duration");
writer.RenderEndTag();
writer.AddAttribute("class", "ww-code");
writer.RenderBeginTag(HtmlTextWriterTag.Span);
writer.WriteEncodedText(this.Duration);
writer.RenderEndTag();
}