本文整理汇总了C#中System.Web.UI.HtmlTextWriter.AddStyleAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlTextWriter.AddStyleAttribute方法的具体用法?C# HtmlTextWriter.AddStyleAttribute怎么用?C# HtmlTextWriter.AddStyleAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.HtmlTextWriter
的用法示例。
在下文中一共展示了HtmlTextWriter.AddStyleAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenderChildren
protected override void RenderChildren( HtmlTextWriter writer )
{
writer.AddAttribute( HtmlTextWriterAttribute.Cellpadding, "0" );
writer.AddAttribute( HtmlTextWriterAttribute.Cellspacing, "0" );
writer.RenderBeginTag( HtmlTextWriterTag.Table );
writer.RenderBeginTag( HtmlTextWriterTag.Tr );
foreach(Control control in Controls)
{
ContextListItem item = control as ContextListItem;
if(item == null) continue;
// если команда видима и доступна
if(item.Visible && item.IsAccessible)
{
// создаем ячейку
writer.RenderBeginTag( HtmlTextWriterTag.Td );
item.RenderControl( writer );
writer.RenderEndTag();
writer.AddStyleAttribute( HtmlTextWriterStyle.PaddingLeft, "5px" );
writer.AddStyleAttribute( HtmlTextWriterStyle.PaddingRight, "5px" );
writer.RenderBeginTag( HtmlTextWriterTag.Td );
writer.Write( "|" );
writer.RenderEndTag( );
}
}
writer.RenderEndTag(); // </tr>
writer.RenderEndTag(); // </table>
}
示例2: RenderBeginGroup
internal virtual void RenderBeginGroup (HtmlTextWriter output, GroupInfo group) {
output.AddStyleAttribute ("clear", "both");
output.AddStyleAttribute (HtmlTextWriterStyle.Width, "100%");
output.RenderBeginTag (HtmlTextWriterTag.Div);
output.Write (HttpUtility.HtmlEncode (group.Name));
output.RenderEndTag ();
}
示例3: RenderEndTag
public override void RenderEndTag(HtmlTextWriter writer)
{
writer.RenderEndTag();
writer.AddStyleAttribute(HtmlTextWriterStyle.Height, Height.Value - 40 + "px");
writer.AddAttribute(HtmlTextWriterAttribute.Class, "right");
writer.RenderBeginTag(HtmlTextWriterTag.Div);
writer.RenderEndTag();
writer.RenderEndTag();
writer.AddStyleAttribute(HtmlTextWriterStyle.Width, Width.Value + "px");
writer.AddAttribute(HtmlTextWriterAttribute.Class, "bottom");
writer.RenderBeginTag(HtmlTextWriterTag.Div);
writer.AddAttribute(HtmlTextWriterAttribute.Class, "left");
writer.RenderBeginTag(HtmlTextWriterTag.Div);
writer.RenderEndTag();
writer.AddAttribute(HtmlTextWriterAttribute.Class, "right");
writer.RenderBeginTag(HtmlTextWriterTag.Div);
writer.RenderEndTag();
writer.RenderEndTag();
base.RenderEndTag(writer);
}
示例4: Main
static void Main(string[] args)
{
if (args.Length < 3)
{
Console.WriteLine("GEBRUIK: BarcodeGenerator <aantal Klein> <aantal Groot> <outputbestand>");
}
int kleinAmount = int.Parse(args[0]);
int grootAmount = int.Parse(args[1]);
string outfile = args[2];
TextWriter writer = new StreamWriter(outfile);
HtmlTextWriter html = new HtmlTextWriter(writer);
html.RenderBeginTag(HtmlTextWriterTag.Html);
html.RenderBeginTag(HtmlTextWriterTag.Head);
html.RenderBeginTag(HtmlTextWriterTag.Title);
html.Write("JOTARI QR-codes");
html.RenderEndTag();
html.RenderEndTag();
html.AddStyleAttribute(HtmlTextWriterStyle.FontFamily, "Arial");
html.AddStyleAttribute(HtmlTextWriterStyle.FontSize, "20");
html.Write(html.NewLine);
html.RenderBeginTag(HtmlTextWriterTag.Body);
//html.RenderBeginTag(HtmlTextWriterTag.Table);
WriteQrCodes(html, kleinAmount, grootAmount, 3);
//html.RenderEndTag();
html.RenderEndTag();
html.RenderEndTag();
writer.Close();
}
示例5: TestListSection
public TestListSection(List<NunitGoTest> tests, string height = "90%")
{
var tree = new Tree(tests);
var stringWriter = new StringWriter();
using (var writer = new HtmlTextWriter(stringWriter))
{
writer.AddStyleAttribute(HtmlTextWriterStyle.Height, height);
writer.AddStyleAttribute(HtmlTextWriterStyle.BackgroundColor, Colors.White);
writer.AddStyleAttribute(HtmlTextWriterStyle.Overflow, "scroll");
writer.RenderBeginTag(HtmlTextWriterTag.Div);
writer.AddStyleAttribute(HtmlTextWriterStyle.Margin, "1% 2% 3% 97%");
writer.RenderBeginTag(HtmlTextWriterTag.Div);
writer.Write(new CloseButton("Back", Output.Files.FullReportFile).ButtonHtml);
writer.RenderEndTag(); //DIV
writer.AddStyleAttribute(HtmlTextWriterStyle.Margin, "5%");
writer.RenderBeginTag(HtmlTextWriterTag.Div);
writer.Write(tree.HtmlCode);
writer.RenderEndTag(); //DIV
writer.RenderEndTag(); //DIV
}
HtmlCode = stringWriter.ToString();
}
示例6: 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();
}
示例7: Render
protected override void Render(HtmlTextWriter writer)
{
string width = this.Width.Value.ToString();
string height = this.Height.Value.ToString();
writer.AddStyleAttribute(HtmlTextWriterStyle.Width, this.Width.Value.ToString());
writer.AddStyleAttribute(HtmlTextWriterStyle.Height, this.Height.Value.ToString());
writer.AddAttribute(HtmlTextWriterAttribute.Id, this.ClientID);
writer.AddAttribute(HtmlTextWriterAttribute.Class, "updateProgressPanel");
writer.RenderBeginTag(HtmlTextWriterTag.Div);
if (this.ContentType == UpdateProgressContentType.Image)
{
writer.AddAttribute(HtmlTextWriterAttribute.Src, this.ResolveClientUrl(this.ImageUrl));
writer.AddAttribute(HtmlTextWriterAttribute.Alt, this.Text);
writer.RenderBeginTag(HtmlTextWriterTag.Img);
}
else
{
writer.RenderBeginTag(HtmlTextWriterTag.Div);
writer.Write(this.Text);
}
writer.RenderEndTag();
writer.RenderEndTag();
//ClientScriptManager csm = this.Page.ClientScript;
//string scriptKey = this.ClientID + "_LoadScript";
//if (!csm.IsClientScriptBlockRegistered(scriptKey))
//{
// string script = string.Format("SetUpdateProgressPanelSytle('{0}', {{width:{1}, height:{2}}});", this.ClientID, width, height);
// csm.RegisterClientScriptBlock(this.GetType(), scriptKey, script, true);
//}
}
示例8: RenderContents
protected override void RenderContents(HtmlTextWriter output)
{
DateTime CurrentDate = DateTime.Today;
DayOfWeek FirstDayOfWeek = CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek;
while (CurrentDate.DayOfWeek != FirstDayOfWeek)
{
CurrentDate = CurrentDate.AddDays(-1);
}
DateTime EndDate = CurrentDate.AddDays(7);
int NumberOfDays = (int)((EndDate - CurrentDate).TotalDays);
List<DateTime> DatesForOneWeek = Enumerable
//creates an IEnumerable of ints from 0 to numDays
.Range(0, NumberOfDays)
//now for each of those numbers (0..numDays),
//select startDate plus x number of days
.Select(x => CurrentDate.AddDays(x))
//and make a list
.ToList();
DateTime TodayDate = DateTime.Now;
foreach (DateTime CurrentDateTime in DatesForOneWeek)
{
if (CurrentDateTime.DayOfWeek == TodayDate.DayOfWeek)
{
output.AddStyleAttribute(HtmlTextWriterStyle.Color, "red");
output.AddStyleAttribute(HtmlTextWriterStyle.FontWeight, "bold");
output.AddStyleAttribute(HtmlTextWriterStyle.TextDecoration, "underline");
}
output.RenderBeginTag(HtmlTextWriterTag.P);
output.Write(CurrentDateTime.DayOfWeek.ToString());
output.RenderEndTag();
}
}
示例9: Render
//-------------------------------------------------------------------------------------------
protected override void Render(HtmlTextWriter writer)
{
if (!Visible)
{
return;
}
writer.AddStyleAttribute(HtmlTextWriterStyle.BorderStyle, BorderStyle.ToString());
writer.AddStyleAttribute(HtmlTextWriterStyle.BorderWidth, BorderWidth.ToString());
writer.AddAttribute(HtmlTextWriterAttribute.Width, Width.ToString());
writer.AddAttribute(HtmlTextWriterAttribute.Href, Height.ToString());
writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0");
writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0");
writer.AddAttribute(HtmlTextWriterAttribute.Align, "center");
writer.RenderBeginTag("table");
writer.AddAttribute(HtmlTextWriterAttribute.Class, "groupboxtitle");
writer.RenderBeginTag("tr");
writer.AddAttribute(HtmlTextWriterAttribute.Background, "images/group-box-bar.gif");
writer.RenderBeginTag("td");
writer.Write(Text);
writer.RenderEndTag();
writer.RenderEndTag();
for (int i = 0; i < Items.Count; i++)
{
RenderItemRow(writer, Items[i]);
}
writer.RenderEndTag();
}
示例10: RenderCustomInfoSection
private void RenderCustomInfoSection(HtmlTextWriter writer)
{
if (Height != Unit.Empty)
writer.AddStyleAttribute(HtmlTextWriterStyle.Height, Height.ToString());
string customUnit = CustomInfoSectionWidth.ToString();
if (CustomInfoClass != null && CustomInfoClass.Trim().Length > 0)
writer.AddAttribute(HtmlTextWriterAttribute.Class, CustomInfoClass);
if (CustomInfoStyle != null && CustomInfoStyle.Trim().Length > 0)
writer.AddAttribute(HtmlTextWriterAttribute.Style, CustomInfoStyle);
writer.AddStyleAttribute(HtmlTextWriterStyle.Width, customUnit);
if (CustomInfoTextAlign != HorizontalAlign.NotSet)
writer.AddAttribute(HtmlTextWriterAttribute.Align, CustomInfoTextAlign.ToString().ToLower());
if (LayoutType == LayoutType.Table)
{
writer.AddAttribute(HtmlTextWriterAttribute.Valign, "bottom");
writer.AddAttribute(HtmlTextWriterAttribute.Nowrap, "true");
writer.RenderBeginTag(HtmlTextWriterTag.Td);
}
else
{
writer.AddStyleAttribute("float", "left");
writer.RenderBeginTag(HtmlTextWriterTag.Div);
}
writer.Write(GetCustomInfoHtml(CustomInfoHTML));
writer.RenderEndTag();
}
示例11: _sgv_RenderBegin
/// <summary>
/// RenderBegin
/// </summary>
/// <param name="sender"></param>
/// <param name="writer"></param>
void _sgv_RenderBegin(object sender, HtmlTextWriter writer)
{
writer.AddStyleAttribute(HtmlTextWriterStyle.Overflow, "auto");
writer.AddStyleAttribute(HtmlTextWriterStyle.Position, "relative");
writer.AddStyleAttribute(HtmlTextWriterStyle.Width, String.IsNullOrEmpty(this._sgv.FixRowColumn.TableWidth) ? "100%" : this._sgv.FixRowColumn.TableWidth);
writer.AddStyleAttribute(HtmlTextWriterStyle.Height, String.IsNullOrEmpty(this._sgv.FixRowColumn.TableHeight) ? "100%" : this._sgv.FixRowColumn.TableHeight);
writer.RenderBeginTag(HtmlTextWriterTag.Div);
}
示例12: RenderContents
protected override void RenderContents(HtmlTextWriter writer)
{
writer.AddStyleAttribute(HtmlTextWriterStyle.Color, "Blue");
writer.AddStyleAttribute(HtmlTextWriterStyle.FontSize, "18px");
writer.RenderBeginTag(HtmlTextWriterTag.Div);
writer.Write("Hello World");
writer.RenderEndTag(); // </div>
}
示例13: AddAttributesToRender
protected override void AddAttributesToRender(HtmlTextWriter writer)
{
bool flag = false;
switch (this.BulletStyle)
{
case System.Web.UI.WebControls.BulletStyle.Numbered:
writer.AddStyleAttribute(HtmlTextWriterStyle.ListStyleType, "decimal");
flag = true;
break;
case System.Web.UI.WebControls.BulletStyle.LowerAlpha:
writer.AddStyleAttribute(HtmlTextWriterStyle.ListStyleType, "lower-alpha");
flag = true;
break;
case System.Web.UI.WebControls.BulletStyle.UpperAlpha:
writer.AddStyleAttribute(HtmlTextWriterStyle.ListStyleType, "upper-alpha");
flag = true;
break;
case System.Web.UI.WebControls.BulletStyle.LowerRoman:
writer.AddStyleAttribute(HtmlTextWriterStyle.ListStyleType, "lower-roman");
flag = true;
break;
case System.Web.UI.WebControls.BulletStyle.UpperRoman:
writer.AddStyleAttribute(HtmlTextWriterStyle.ListStyleType, "upper-roman");
flag = true;
break;
case System.Web.UI.WebControls.BulletStyle.Disc:
writer.AddStyleAttribute(HtmlTextWriterStyle.ListStyleType, "disc");
break;
case System.Web.UI.WebControls.BulletStyle.Circle:
writer.AddStyleAttribute(HtmlTextWriterStyle.ListStyleType, "circle");
break;
case System.Web.UI.WebControls.BulletStyle.Square:
writer.AddStyleAttribute(HtmlTextWriterStyle.ListStyleType, "square");
break;
case System.Web.UI.WebControls.BulletStyle.CustomImage:
{
string str = base.ResolveClientUrl(this.BulletImageUrl);
writer.AddStyleAttribute(HtmlTextWriterStyle.ListStyleImage, "url(" + HttpUtility.UrlPathEncode(str) + ")");
break;
}
}
int firstBulletNumber = this.FirstBulletNumber;
if (flag && (firstBulletNumber != 1))
{
writer.AddAttribute("start", firstBulletNumber.ToString(CultureInfo.InvariantCulture));
}
base.AddAttributesToRender(writer);
}
示例14: RenderContents
/// <summary>
/// Renders the contents of the control to the specified writer. This method is used primarily by control developers.
/// </summary>
/// <param name="writer">A <see cref="T:System.Web.UI.HtmlTextWriter"/> that represents the output stream to render HTML content on the client.</param>
protected override void RenderContents(HtmlTextWriter writer)
{
if (this.EventArgs != null) {
writer.RenderTag(HtmlTextWriterTag.Legend, "Server side rendered content");
// start address/location
writer.AddStyleAttribute(HtmlTextWriterStyle.BackgroundColor, "#EEE");
using (writer.BeginTag(HtmlTextWriterTag.Div)) {
writer.RenderTag(HtmlTextWriterTag.B, "Start address: ");
writer.Write(this.EventArgs.StartAddress);
writer.RenderTag(HtmlTextWriterTag.B, " / Start location: ");
writer.Write(this.EventArgs.StartLocation.ToString());
}
// steps
foreach (var step in this.EventArgs.Steps) {
writer.AddStyleAttribute("border-bottom", "solid 1px #CCC");
using (writer.BeginTag(HtmlTextWriterTag.Div)) {
writer.Write(step.Instructions);
writer.Write(" | ");
writer.RenderTag(HtmlTextWriterTag.B, "Distance: ");
writer.Write(step.Distance.Text);
writer.Write(" | ");
writer.RenderTag(HtmlTextWriterTag.B, "Duration: ");
writer.Write(step.Duration.Text);
}
}
// end address/location
writer.AddStyleAttribute(HtmlTextWriterStyle.BackgroundColor, "#EEE");
using (writer.BeginTag(HtmlTextWriterTag.Div)) {
writer.RenderTag(HtmlTextWriterTag.B, "End address: ");
writer.Write(this.EventArgs.EndAddress);
writer.RenderTag(HtmlTextWriterTag.B, " / End location: ");
writer.Write(this.EventArgs.EndLocation.ToString());
}
// distance
using (writer.BeginTag(HtmlTextWriterTag.Div)) {
writer.RenderTag(HtmlTextWriterTag.B, "Total Distance: ");
writer.Write(this.EventArgs.Distance.Text);
}
// durarion
using (writer.BeginTag(HtmlTextWriterTag.Div)) {
writer.RenderTag(HtmlTextWriterTag.B, "Total Duration: ");
writer.Write(this.EventArgs.Duration.Text);
}
}
}
示例15: PerformExpand
/// <summary>
/// Will expand the input into the appropriate content based on scope.
/// </summary>
/// <param name="scopeName">The scope name.</param>
/// <param name="input">The input to be expanded.</param>
/// <param name="htmlEncode">Function that will html encode the output.</param>
/// <param name="attributeEncode">Function that will html attribute encode the output.</param>
/// <returns>The expanded content.</returns>
protected override string PerformExpand(string scopeName, string input, Func<string, string> htmlEncode, Func<string, string> attributeEncode)
{
string[] parameters = input.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries);
string url = Parameters.ExtractUrl(parameters);
Dimensions dimensions = Parameters.ExtractDimensions(parameters, 200, 200);
bool gpuAcceleration = Parameters.ExtractBool(parameters, "gpuAcceleration", false);
string versionValue;
int version = 5;
if (Parameters.TryGetValue(parameters, "version", out versionValue) && int.TryParse(versionValue, out version))
{
if (version < 2 || version > 5)
version = 5;
}
if (version == 2 && gpuAcceleration)
throw new RenderException("Cannot resolve silverlight macro, 'gpuAcceleration' cannot be enabled with version 2 of Silverlight.");
string[] initParams = GetInitParams(parameters);
ISilverlightRenderer renderer = GetRenderer(version);
var content = new StringBuilder();
using (var tw = new StringWriter(content))
using (var writer = new HtmlTextWriter(tw, string.Empty))
{
writer.NewLine = string.Empty;
renderer.AddObjectTagAttributes(writer);
writer.AddStyleAttribute(HtmlTextWriterStyle.Height, dimensions.Height.ToString());
writer.AddStyleAttribute(HtmlTextWriterStyle.Width, dimensions.Width.ToString());
writer.RenderBeginTag(HtmlTextWriterTag.Object);
renderer.AddParameterTags(url, gpuAcceleration, initParams, writer);
renderer.AddDownloadLink(writer);
writer.RenderEndTag(); // object
writer.AddStyleAttribute(HtmlTextWriterStyle.Visibility, "hidden");
writer.AddStyleAttribute(HtmlTextWriterStyle.Height, "0");
writer.AddStyleAttribute(HtmlTextWriterStyle.Width, "0");
writer.AddStyleAttribute(HtmlTextWriterStyle.BorderWidth, "0");
writer.RenderBeginTag(HtmlTextWriterTag.Iframe);
writer.RenderEndTag();
}
return content.ToString();
}