本文整理汇总了C#中System.Web.UI.WebControls.WebControl.CopyBaseAttributes方法的典型用法代码示例。如果您正苦于以下问题:C# WebControl.CopyBaseAttributes方法的具体用法?C# WebControl.CopyBaseAttributes怎么用?C# WebControl.CopyBaseAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.WebControls.WebControl
的用法示例。
在下文中一共展示了WebControl.CopyBaseAttributes方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CopyBaseAttributesToInnerControl
internal static void CopyBaseAttributesToInnerControl(WebControl control, WebControl child) {
short oldTab = control.TabIndex;
string oldAccess = control.AccessKey;
try {
control.AccessKey = String.Empty;
control.TabIndex = 0;
child.CopyBaseAttributes(control);
}
finally {
control.TabIndex = oldTab;
control.AccessKey = oldAccess;
}
}
示例2: OnPreRender
protected override void OnPreRender(System.EventArgs e)
{
base.OnPreRender(e);
WebControl div = new WebControl(System.Web.UI.HtmlTextWriterTag.Div);
LayoutTemplate.InstantiateIn(div);
div.CopyBaseAttributes(this);
div.CssClass = this.CssClass;
for (int i = 0; i < this.Controls[0].Controls.Count; i++ )
{
if (Controls[0].Controls[i] as ITextControl != null)
{
((ITextControl)div.Controls[i]).Text = ((ITextControl)Controls[0].Controls[i]).Text;
}
}
Controls.Clear();
Controls.Add(div);
}
示例3: 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);
}
示例4: CopyBaseAttributesToInnerControl
internal static void CopyBaseAttributesToInnerControl(WebControl control, WebControl child)
{
short tabIndex = control.TabIndex;
string accessKey = control.AccessKey;
try
{
control.AccessKey = string.Empty;
control.TabIndex = 0;
child.CopyBaseAttributes(control);
}
finally
{
control.TabIndex = tabIndex;
control.AccessKey = accessKey;
}
}
示例5: 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 );
}
}
}
示例6: 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)
//.........这里部分代码省略.........
示例7: 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)
{
//.........这里部分代码省略.........