本文整理汇总了C#中System.Web.UI.WebControls.WebControl.RenderBeginTag方法的典型用法代码示例。如果您正苦于以下问题:C# WebControl.RenderBeginTag方法的具体用法?C# WebControl.RenderBeginTag怎么用?C# WebControl.RenderBeginTag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.WebControls.WebControl
的用法示例。
在下文中一共展示了WebControl.RenderBeginTag方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenderBeginTag_BorderWidth_table
public void RenderBeginTag_BorderWidth_table ()
{
HtmlTextWriter writer = WebControlTest.GetWriter ();
WebControl wc = new WebControl (HtmlTextWriterTag.Table);
wc.BorderWidth = Unit.Pixel (1);
wc.RenderBeginTag (writer);
string s = writer.InnerWriter.ToString ();
Assert.AreEqual ("<table style=\"border-width:1px;border-style:solid;\">\n", s, "BorderWidth");
}
示例2: RenderBeginTag
void RenderBeginTag (HtmlTextWriter w, Style s, WebControl wc)
{
WebControl c;
switch (RepeatLayout) {
case RepeatLayout.Table:
c = new Table ();
break;
case RepeatLayout.Flow:
c = new Label ();
break;
case RepeatLayout.OrderedList:
c = new WebControl (HtmlTextWriterTag.Ol);
break;
case RepeatLayout.UnorderedList:
c = new WebControl (HtmlTextWriterTag.Ul);
break;
default:
throw new InvalidOperationException (String.Format ("Unsupported RepeatLayout value '{0}'.", RepeatLayout));
}
c.ID = wc.ClientID;
c.CopyBaseAttributes (wc);
c.ApplyStyle (s);
c.Enabled = wc.IsEnabled;
c.RenderBeginTag (w);
}
示例3: RenderBeginTag_Style
public void RenderBeginTag_Style ()
{
HtmlTextWriter writer = WebControlTest.GetWriter ();
WebControl wc = new WebControl (HtmlTextWriterTag.Table);
wc.BackColor = Color.Aqua;
wc.RenderBeginTag (writer);
string s = writer.InnerWriter.ToString ();
Assert.AreEqual ("<table style=\"background-color:Aqua;\">\n", s, "BackColor");
writer = WebControlTest.GetWriter ();
wc.BackColor = new Color ();
Assert.IsTrue (wc.BackColor.IsEmpty, "IsEmpty");
wc.RenderBeginTag (writer);
s = writer.InnerWriter.ToString ();
Assert.AreEqual ("<table>\n", s, "-BackColor");
}
示例4: RenderBeginTag_BorderWidth_span
public void RenderBeginTag_BorderWidth_span ()
{
HtmlTextWriter writer = WebControlTest.GetWriter ();
WebControl wc = new WebControl (HtmlTextWriterTag.Span);
wc.BorderWidth = Unit.Pixel (1);
wc.RenderBeginTag (writer);
string s = writer.InnerWriter.ToString ();
#if NET_2_0
Assert.AreEqual ("<span style=\"display:inline-block;border-width:1px;border-style:solid;\">", s, "BorderWidth");
#else
Assert.AreEqual ("<span style=\"border-width:1px;border-style:solid;\">", s, "BorderWidth");
#endif
}
示例5: RenderBeginTag_Attributes
public void RenderBeginTag_Attributes ()
{
HtmlTextWriter writer = WebControlTest.GetWriter ();
WebControl wc = new WebControl (HtmlTextWriterTag.Table);
wc.ID = "test1";
wc.RenderBeginTag (writer);
string s = writer.InnerWriter.ToString ();
Assert.AreEqual ("<table id=\"test1\">\n", s, "ID");
writer = WebControlTest.GetWriter ();
wc.ID = null;
Assert.IsNull (wc.ID, "ID");
wc.RenderBeginTag (writer);
s = writer.InnerWriter.ToString ();
Assert.AreEqual ("<table>\n", s, "-ID");
}
示例6: RenderBeginTag_TagOnly
public void RenderBeginTag_TagOnly ()
{
HtmlTextWriter writer = WebControlTest.GetWriter ();
WebControl wc = new WebControl (HtmlTextWriterTag.Table);
wc.RenderBeginTag (writer);
string s = writer.InnerWriter.ToString ();
Assert.AreEqual ("<table>\n", s, "table");
}
示例7: RenderContents
/// <summary>
/// Generates the target-specific inner markup for the Web control to which the control adapter is attached.
/// </summary>
/// <param name="writer">The <see cref="T:System.Web.UI.HtmlTextWriter" /> containing methods to render the target-specific output.</param>
protected override void RenderContents( System.Web.UI.HtmlTextWriter writer )
{
RadioButtonList rbl = Control as RadioButtonList;
if ( rbl != null )
{
PostBackOptions postBackOption = null;
if ( rbl.AutoPostBack )
{
postBackOption = new PostBackOptions( rbl, string.Empty );
if ( rbl.CausesValidation && this.Page.GetValidators( rbl.ValidationGroup ).Count > 0 )
{
postBackOption.PerformValidation = true;
postBackOption.ValidationGroup = rbl.ValidationGroup;
}
if ( this.Page.Form != null )
{
postBackOption.AutoPostBack = true;
}
}
WebControl control = new WebControl(HtmlTextWriterTag.Span);
control.ID = rbl.ClientID;
control.CopyBaseAttributes(rbl);
control.RenderBeginTag(writer);
int i = 0;
foreach ( ListItem li in rbl.Items )
{
writer.WriteLine();
if ( rbl.RepeatDirection == RepeatDirection.Vertical )
{
writer.AddAttribute( "class", "radio" );
writer.RenderBeginTag( HtmlTextWriterTag.Div );
}
else
{
writer.AddAttribute( "class", "radio-inline" );
}
writer.RenderBeginTag( HtmlTextWriterTag.Label );
string itemId = string.Format( "{0}_{1}", rbl.ClientID, i++ );
writer.AddAttribute( "id", itemId );
writer.AddAttribute( "type", "radio" );
writer.AddAttribute( "name", rbl.UniqueID );
writer.AddAttribute( "value", li.Value );
if ( li.Selected )
{
writer.AddAttribute( "checked", "checked" );
}
foreach ( var attributeKey in li.Attributes.Keys )
{
var key = attributeKey as string;
writer.AddAttribute( key, li.Attributes[key] );
}
if ( postBackOption != null )
{
writer.AddAttribute( HtmlTextWriterAttribute.Onclick, Page.ClientScript.GetPostBackEventReference( postBackOption, true ) );
}
writer.RenderBeginTag( HtmlTextWriterTag.Input );
writer.RenderEndTag();
writer.Write( li.Text );
writer.RenderEndTag(); // Label
if ( rbl.RepeatDirection == RepeatDirection.Vertical )
{
writer.RenderEndTag(); // Div
}
if ( rbl.Page != null )
{
rbl.Page.ClientScript.RegisterForEventValidation( rbl.UniqueID, li.Value );
}
}
control.RenderEndTag( writer );
if ( rbl.Page != null )
{
rbl.Page.ClientScript.RegisterForEventValidation( rbl.UniqueID );
}
}
}
示例8: RenderHorizontalRepeater
/// <devdoc>
/// </devdoc>
private void RenderHorizontalRepeater(HtmlTextWriter writer, IRepeatInfoUser user, Style controlStyle, WebControl baseControl) {
Debug.Assert(outerTableImplied == false, "Cannot use outer implied table with Horizontal layout");
int itemCount = user.RepeatedItemCount;
int totalColumns = repeatColumns;
int currentColumn = 0;
if (totalColumns == 0) {
// 0 implies a complete horizontal repetition without any
// column count constraints
totalColumns = itemCount;
}
WebControl outerControl = null;
bool tableLayout = false;
switch (repeatLayout) {
case RepeatLayout.Table:
outerControl = new Table();
if (Caption.Length != 0) {
((Table)outerControl).Caption = Caption;
((Table)outerControl).CaptionAlign = CaptionAlign;
}
tableLayout = true;
break;
case RepeatLayout.Flow:
outerControl = new WebControl(HtmlTextWriterTag.Span);
break;
}
bool separators = user.HasSeparators;
// use ClientID (and not ID) since we want to render out the fully qualified client id
// even though this outer control will not be parented to the control hierarchy
outerControl.ID = baseControl.ClientID;
outerControl.CopyBaseAttributes(baseControl);
outerControl.ApplyStyle(controlStyle);
outerControl.RenderBeginTag(writer);
if (user.HasHeader) {
if (tableLayout) {
writer.RenderBeginTag(HtmlTextWriterTag.Tr);
// add attributes to render for TD/TH
if ((totalColumns != 1) || separators) {
int columnSpan = totalColumns;
if (separators)
columnSpan += totalColumns;
writer.AddAttribute(HtmlTextWriterAttribute.Colspan, columnSpan.ToString(NumberFormatInfo.InvariantInfo));
}
if (useAccessibleHeader) {
writer.AddAttribute(HtmlTextWriterAttribute.Scope, "col");
}
// add style attributes to render for TD/TH
Style style = user.GetItemStyle(ListItemType.Header, -1);
if (style != null) {
style.AddAttributesToRender(writer);
}
// render begin tag
if (useAccessibleHeader) {
writer.RenderBeginTag(HtmlTextWriterTag.Th);
}
else {
writer.RenderBeginTag(HtmlTextWriterTag.Td);
}
}
user.RenderItem(ListItemType.Header, -1, this, writer);
if (tableLayout) {
// render end tags TD/TH and TR
writer.RenderEndTag();
writer.RenderEndTag();
}
else {
if (totalColumns < itemCount) {
// we have multiple rows, so have a break between the header and first row.
if (EnableLegacyRendering) {
writer.WriteObsoleteBreak();
}
else {
writer.WriteBreak();
}
}
}
}
for (int i = 0; i < itemCount; i++) {
if (tableLayout && (currentColumn == 0)) {
writer.RenderBeginTag(HtmlTextWriterTag.Tr);
}
if (tableLayout) {
// add style attributes to render for TD
Style style = user.GetItemStyle(ListItemType.Item, i);
if (style != null)
//.........这里部分代码省略.........
示例9: RenderHorizontalRepeater
private void RenderHorizontalRepeater(HtmlTextWriter writer, IRepeatInfoUser user, Style controlStyle, WebControl baseControl)
{
int repeatedItemCount = user.RepeatedItemCount;
int repeatColumns = this.repeatColumns;
int num3 = 0;
if (repeatColumns == 0)
{
repeatColumns = repeatedItemCount;
}
WebControl control = null;
bool flag = false;
switch (this.repeatLayout)
{
case System.Web.UI.WebControls.RepeatLayout.Table:
control = new Table();
if (this.Caption.Length != 0)
{
((Table) control).Caption = this.Caption;
((Table) control).CaptionAlign = this.CaptionAlign;
}
flag = true;
break;
case System.Web.UI.WebControls.RepeatLayout.Flow:
control = new WebControl(HtmlTextWriterTag.Span);
break;
}
bool hasSeparators = user.HasSeparators;
control.ID = baseControl.ClientID;
control.CopyBaseAttributes(baseControl);
control.ApplyStyle(controlStyle);
control.RenderBeginTag(writer);
if (user.HasHeader)
{
if (flag)
{
writer.RenderBeginTag(HtmlTextWriterTag.Tr);
if ((repeatColumns != 1) || hasSeparators)
{
int num4 = repeatColumns;
if (hasSeparators)
{
num4 += repeatColumns;
}
writer.AddAttribute(HtmlTextWriterAttribute.Colspan, num4.ToString(NumberFormatInfo.InvariantInfo));
}
if (this.useAccessibleHeader)
{
writer.AddAttribute(HtmlTextWriterAttribute.Scope, "col");
}
Style itemStyle = user.GetItemStyle(ListItemType.Header, -1);
if (itemStyle != null)
{
itemStyle.AddAttributesToRender(writer);
}
if (this.useAccessibleHeader)
{
writer.RenderBeginTag(HtmlTextWriterTag.Th);
}
else
{
writer.RenderBeginTag(HtmlTextWriterTag.Td);
}
}
user.RenderItem(ListItemType.Header, -1, this, writer);
if (flag)
{
writer.RenderEndTag();
writer.RenderEndTag();
}
else if (repeatColumns < repeatedItemCount)
{
if (this.EnableLegacyRendering)
{
writer.WriteObsoleteBreak();
}
else
{
writer.WriteBreak();
}
}
}
for (int i = 0; i < repeatedItemCount; i++)
{
if (flag && (num3 == 0))
{
writer.RenderBeginTag(HtmlTextWriterTag.Tr);
}
if (flag)
{
Style style2 = user.GetItemStyle(ListItemType.Item, i);
if (style2 != null)
{
style2.AddAttributesToRender(writer);
}
writer.RenderBeginTag(HtmlTextWriterTag.Td);
}
user.RenderItem(ListItemType.Item, i, this, writer);
if (flag)
{
//.........这里部分代码省略.........