本文整理汇总了C#中System.Web.UI.HtmlTextWriter.AddAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlTextWriter.AddAttribute方法的具体用法?C# HtmlTextWriter.AddAttribute怎么用?C# HtmlTextWriter.AddAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.HtmlTextWriter
的用法示例。
在下文中一共展示了HtmlTextWriter.AddAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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();
}
示例2: RenderControl
/// <summary>
/// Outputs server control content to a provided <see cref="T:System.Web.UI.HtmlTextWriter" /> object and stores tracing information about the control if tracing is enabled.
/// </summary>
/// <param name="writer">The <see cref="T:System.Web.UI.HtmlTextWriter" /> object that receives the control content.</param>
public override void RenderControl( HtmlTextWriter writer )
{
if ( this.Text.Trim() != string.Empty )
{
writer.AddAttribute( "class", "warning" );
writer.AddAttribute( "href", "#" );
writer.AddAttribute( "tabindex", "-1" );
foreach (var key in this.Style.Keys.OfType<HtmlTextWriterStyle>())
{
writer.AddStyleAttribute( key, this.Style[key] );
}
writer.RenderBeginTag( HtmlTextWriterTag.A );
writer.AddAttribute("class", "fa fa-exclamation-triangle");
writer.RenderBeginTag( HtmlTextWriterTag.I );
writer.RenderEndTag();
writer.RenderEndTag();
writer.AddAttribute( "class", "alert alert-warning warning-message" );
writer.AddAttribute( "style", "display:none" );
writer.RenderBeginTag( HtmlTextWriterTag.Div );
writer.RenderBeginTag( HtmlTextWriterTag.Small );
writer.Write( this.Text.Trim() );
writer.RenderEndTag();
writer.RenderEndTag();
}
}
示例3: RenderBeginTag
protected override void RenderBeginTag(HtmlTextWriter writer)
{
writer.Indent++;
// Div
writer.AddAttribute(HtmlTextWriterAttribute.Id, this.Control.ClientID);
// inject the asp.RadioButtonList css entries into the new HTML ouput generated.
string cssClass = String.Empty;
if (!string.IsNullOrEmpty(this.Control.CssClass))
{
cssClass = Helpers.BuildClassList(cssClass, this.Control.CssClass);
}
RadioButtonList controlList = this.Control as RadioButtonList;
if (controlList != null)
{
if (controlList.RepeatDirection == RepeatDirection.Horizontal)
{
cssClass = Helpers.BuildClassList(cssClass, CBootstrapFormInlineLayoutClassName);
}
}
if (!string.IsNullOrEmpty(cssClass.Trim()))
{
writer.AddAttribute(HtmlTextWriterAttribute.Class, cssClass.Trim());
}
}
示例4: AddAttributesToRender
/// <summary>
/// Overrides <see cref="WebControl.AddAttributesToRender"/>
/// </summary>
protected override void AddAttributesToRender(HtmlTextWriter writer)
{
writer.AddAttribute(HtmlTextWriterAttribute.Type,"button");
writer.AddAttribute("value",this.Text);
writer.AddAttribute("language","javascript");
String myOnclick = " return false; ";
// prepend the dialog open script to the onclick script
if ( System.Web.HttpContext.Current != null && this.Page != null && this.Enabled && this.DialogToOpen != null && this.DialogToOpen.Length != 0 ) {
DialogWindowBase dialog = this.NamingContainer.FindControl(this.DialogToOpen) as DialogWindowBase;
if ( dialog == null ) {
dialog = this.Page.FindControl(this.DialogToOpen) as DialogWindowBase;
}
if ( dialog == null ) {
throw new InvalidOperationException("Cannot find a DialogWindow with the name '" + this.DialogToOpen + "'");
}
myOnclick = dialog.GetDialogOpenScript() + "; " + myOnclick;
}
// prepend the user's onclick script to mine
if ( this.Attributes["onclick"] != null ) {
myOnclick = this.Attributes["onclick"] + myOnclick;
this.Attributes.Remove("onclick");
}
// write the final onclick
writer.AddAttribute("onclick", myOnclick);
base.AddAttributesToRender (writer);
}
示例5: AddAttributesToRender
protected override void AddAttributesToRender(HtmlTextWriter writer)
{
string associatedControlID = this.AssociatedControlID;
if (associatedControlID.Length != 0)
{
if (this.AssociatedControlInControlTree)
{
Control control = this.FindControl(associatedControlID);
if (control == null)
{
if (!base.DesignMode)
{
throw new HttpException(System.Web.SR.GetString("LabelForNotFound", new object[] { associatedControlID, this.ID }));
}
}
else
{
writer.AddAttribute(HtmlTextWriterAttribute.For, control.ClientID);
}
}
else
{
writer.AddAttribute(HtmlTextWriterAttribute.For, associatedControlID);
}
}
base.AddAttributesToRender(writer);
}
示例6: RenderLabel
public void RenderLabel(HtmlTextWriter textWriter, FormElement formElement, IFormBuilderParameters formBuilderParameters)
{
var bootStrapBuilderParameters = (BootStrapBuilderParameters)formBuilderParameters;
// if there is a Name specified in the DisplayAttribute use it , other wise use the property name
var displayName = formElement.ControlSpecs.ControlName.SpacePascal();
if (!String.IsNullOrEmpty(formElement.ControlSpecs.Name))
{
displayName = formElement.ControlSpecs.Name;
}
// Label
if (bootStrapBuilderParameters.FormType == BootstrapFormType.Horizontal)
{
textWriter.AddAttribute(HtmlTextWriterAttribute.Class, "col-lg-3 control-label");
}
else
{
textWriter.AddAttribute(HtmlTextWriterAttribute.Class, "control-label");
}
textWriter.AddAttribute(HtmlTextWriterAttribute.For, formElement.ControlSpecs.ControlName);
textWriter.RenderBeginTag(HtmlTextWriterTag.Label);
textWriter.Write(displayName);
textWriter.RenderEndTag(); // label
}
示例7: Render
public void Render(HtmlTextWriter writer)
{
if (CollapseByDefault) writer.Write("<h4 class=\"expand\">{0} Details</h4>", ConfigurationName);
else writer.Write("<h4>{0} Details</h4>", ConfigurationName);
if(CollapseByDefault) writer.AddAttribute("class", "details collapsed");
else writer.AddAttribute("class", "details");
writer.RenderBeginTag("ul");
RenderType("Predicate",
"Predicates define what items get included into Unicorn, because you don't want to serialize everything. You can implement your own to use any criteria for inclusion you can possibly imagine.",
_predicate,
writer);
RenderType("Serialization Provider",
"Defines how items are serialized - for example, using standard Sitecore serialization APIs, JSON to disk, XML in SQL server, etc",
_serializationProvider,
writer);
RenderType("Source Data Provider",
"Defines how source data is read to compare with serialized data. Normally this is a Sitecore database.",
_sourceDataProvider,
writer);
RenderType("Evaluator",
"The evaluator decides what to do when included items need to be evaluated to see if they need updating, creation, or deletion.",
_evaluator,
writer);
writer.RenderEndTag(); // ul
}
示例8: RenderBeginTag
protected override void RenderBeginTag(HtmlTextWriter writer)
{
// Div
writer.AddAttribute(HtmlTextWriterAttribute.Class, WRAPPER_CSS_CLASS);
writer.AddAttribute(HtmlTextWriterAttribute.Id, this.Control.ClientID);
writer.RenderBeginTag(HtmlTextWriterTag.Div);
writer.Indent++;
// Ul
string cssClass = "";
if (!string.IsNullOrEmpty(this.Control.CssClass))
{
cssClass = this.Control.CssClass;
}
CheckBoxList checkList = this.Control as CheckBoxList;
if (checkList != null)
{
cssClass += " " + REPEATDIRECTION_CSS_CLASS + checkList.RepeatDirection.ToString();
}
writer.AddAttribute(HtmlTextWriterAttribute.Class, cssClass.Trim());
writer.RenderBeginTag(HtmlTextWriterTag.Ul);
}
示例9: AddAttributesToRender
protected override void AddAttributesToRender(HtmlTextWriter writer)
{
base.AddAttributesToRender(writer);
if (base.ControlStyleCreated && (base.EnableLegacyRendering || (writer is Html32TextWriter)))
{
Color borderColor = this.BorderColor;
if (!borderColor.IsEmpty)
{
writer.AddAttribute(HtmlTextWriterAttribute.Bordercolor, ColorTranslator.ToHtml(borderColor));
}
}
string str = "0";
bool flag = false;
if (base.ControlStyleCreated)
{
Unit borderWidth = this.BorderWidth;
if (this.GridLines != System.Web.UI.WebControls.GridLines.None)
{
if (borderWidth.IsEmpty || (borderWidth.Type != UnitType.Pixel))
{
str = "1";
flag = true;
}
else
{
str = ((int) borderWidth.Value).ToString(NumberFormatInfo.InvariantInfo);
}
}
}
if ((this.RenderingCompatibility < VersionUtil.Framework40) || flag)
{
writer.AddAttribute(HtmlTextWriterAttribute.Border, str);
}
}
示例10: RenderWebPart
public override void RenderWebPart(HtmlTextWriter writer, WebPart webPart)
{
if (webPart == null)
{
throw new ArgumentNullException("webPart");
}
base.Zone.PartChromeStyle.AddAttributesToRender(writer, base.Zone);
writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0");
writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0");
writer.AddAttribute(HtmlTextWriterAttribute.Border, "0");
writer.AddStyleAttribute(HtmlTextWriterStyle.Width, "100%");
if (webPart.Hidden && !base.WebPartManager.DisplayMode.ShowHiddenWebParts)
{
writer.AddStyleAttribute(HtmlTextWriterStyle.Display, "none");
}
writer.RenderBeginTag(HtmlTextWriterTag.Table);
writer.RenderBeginTag(HtmlTextWriterTag.Tr);
writer.RenderBeginTag(HtmlTextWriterTag.Td);
if (base.WebPartManager.DisplayMode == WebPartManager.EditDisplayMode || webPart.ChromeType != PartChromeType.None)
{
this.RenderTitleBar(writer, webPart);
}
writer.RenderEndTag();
writer.RenderEndTag();
writer.RenderBeginTag(HtmlTextWriterTag.Tr);
base.Zone.PartStyle.AddAttributesToRender(writer, base.Zone);
writer.AddStyleAttribute(HtmlTextWriterStyle.Padding, base.Zone.PartChromePadding.ToString());
writer.RenderBeginTag(HtmlTextWriterTag.Td);
this.RenderPartContents(writer, webPart);
writer.RenderEndTag();
writer.RenderEndTag();
writer.RenderEndTag();
}
示例11: RenderTitleBar
protected virtual void RenderTitleBar(HtmlTextWriter writer, WebPart webPart)
{
writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0");
writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0");
writer.AddAttribute(HtmlTextWriterAttribute.Border, "0");
writer.AddStyleAttribute(HtmlTextWriterStyle.Width, "100%");
writer.RenderBeginTag(HtmlTextWriterTag.Table);
writer.RenderBeginTag(HtmlTextWriterTag.Tr);
base.Zone.PartTitleStyle.AddAttributesToRender(writer, base.Zone);
writer.RenderBeginTag(HtmlTextWriterTag.Td);
writer.AddAttribute(HtmlTextWriterAttribute.Title, webPart.Description, true);
writer.RenderBeginTag(HtmlTextWriterTag.Span);
writer.WriteEncodedText(webPart.Title);
writer.RenderEndTag();
writer.RenderEndTag();
base.Zone.PartTitleStyle.AddAttributesToRender(writer, base.Zone);
writer.AddStyleAttribute(HtmlTextWriterStyle.TextAlign, TextAlign.Right.ToString());
writer.RenderBeginTag(HtmlTextWriterTag.Td);
if (base.WebPartManager.DisplayMode == WebPartManager.EditDisplayMode)
{
this.RenderVerbs(writer, webPart);
}
writer.RenderEndTag();
writer.RenderEndTag();
writer.RenderEndTag();
}
示例12: Render
/// <summary>Renders the control to the specified HTML writer.</summary>
/// <param name="writer">The <see cref="T:System.Web.UI.HtmlTextWriter" /> object that receives the control content.</param>
protected override void Render(HtmlTextWriter writer)
{
this.AddCssClass(this.CssClass);
switch (this.ImageType)
{
case ImageTypes.Rounded:
this.AddCssClass("img-rounded");
break;
case ImageTypes.Circle:
this.AddCssClass("img-circle");
break;
case ImageTypes.Thumbnail:
this.AddCssClass("img-thumbnail");
break;
default:
break;
}
//writer.AddAttribute(HtmlTextWriterAttribute.Id, this.ClientID);
writer.AddAttribute(HtmlTextWriterAttribute.Name, this.UniqueID);
if (!string.IsNullOrEmpty(this.cssClass))
writer.AddAttribute(HtmlTextWriterAttribute.Class, this.cssClass);
base.Render(writer);
}
示例13: AddAttributesToRender
protected override void AddAttributesToRender(HtmlTextWriter writer)
{
writer.AddAttribute(HtmlTextWriterAttribute.Src, MediaManager.GetMediaUrl(MediaItem, _mediaUrlOptions));
writer.AddAttribute(HtmlTextWriterAttribute.Alt, MediaItem.Alt);
base.AddAttributesToRender(writer);
}
示例14: RenderDropDownList
protected void RenderDropDownList(HtmlTextWriter writer, string type, int val)
{
//Render the Select Tag
writer.AddAttribute(HtmlTextWriterAttribute.Type, "text");
writer.AddAttribute(HtmlTextWriterAttribute.Name, UniqueID + "_" + type);
writer.AddStyleAttribute("width", "60px");
writer.RenderBeginTag(HtmlTextWriterTag.Select);
for (int i = 0; i <= 99; i++)
{
//Add the Value Attribute
writer.AddAttribute(HtmlTextWriterAttribute.Value, i.ToString());
if (val == i)
{
//Add the Selected Attribute
writer.AddAttribute(HtmlTextWriterAttribute.Selected, "selected");
}
//Render Option Tag
writer.RenderBeginTag(HtmlTextWriterTag.Option);
writer.Write(i.ToString("00"));
writer.RenderEndTag();
}
//Close Select Tag
writer.RenderEndTag();
}
示例15: Execute
public string Execute(string[] parameters)
{
if (parameters.Any() == false)
{
throw new ArgumentOutOfRangeException();
}
var giphy = new GiphyService();
var search = string.Join(" ", parameters);
var result = giphy.GetGiphyRandom(search);
// Build the image tag
using (var sw = new StringWriter())
{
using (var htmlWriter = new HtmlTextWriter(sw))
{
htmlWriter.AddAttribute(HtmlTextWriterAttribute.Src, result);
htmlWriter.AddAttribute(HtmlTextWriterAttribute.Alt, search);
htmlWriter.RenderBeginTag(HtmlTextWriterTag.Img);
htmlWriter.RenderEndTag();
return sw.ToString();
}
}
}