当前位置: 首页>>代码示例>>C#>>正文


C# WebControl.ApplyStyle方法代码示例

本文整理汇总了C#中System.Web.UI.WebControls.WebControl.ApplyStyle方法的典型用法代码示例。如果您正苦于以下问题:C# WebControl.ApplyStyle方法的具体用法?C# WebControl.ApplyStyle怎么用?C# WebControl.ApplyStyle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.UI.WebControls.WebControl的用法示例。


在下文中一共展示了WebControl.ApplyStyle方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateControl


//.........这里部分代码省略.........
                                    {
                                        if (list is ListItemCollection)
                                            ((ListItemCollection)list).Add("");
                                        else if (list is Dictionary<string, object>)
                                            ((Dictionary<string, object>)list).Add("", "");
                                    }
                                    foreach (IConfigurationElement listItemElement in controlPropertyElement.Elements.Values)
                                    {
                                        string value = null;
                                        string text = null;
                                        string pull = null;
                                        if (listItemElement.Attributes.ContainsKey("value") && null != listItemElement.GetAttributeReference("value").Value)
                                            value = listItemElement.GetAttributeReference("value").Value.ToString();
                                        if (listItemElement.Attributes.ContainsKey("text") && null != listItemElement.GetAttributeReference("text").Value)
                                            text = listItemElement.GetAttributeReference("text").Value.ToString();
                                        if (listItemElement.Attributes.ContainsKey("pull") && null != listItemElement.GetAttributeReference("pull").Value)
                                            pull = listItemElement.GetAttributeReference("pull").Value.ToString();

                                        if (list is ListItemCollection)
                                        {
                                            ListItem li = new ListItem(text, value);
                                            ((ListItemCollection)list).Add(li);
                                            if (null != binder && !String.IsNullOrEmpty(pull))
                                            {
                                                IBindingItem bindingItem = binder.NewBindingItemInstance();
                                                bindingItem.Source = item.Data;
                                                bindingItem.SourceProperty = pull;
                                                bindingItem.Target = li;
                                                bindingItem.TargetProperty = "Text";
                                                bindingItem.Expression = expression;
                                                binder.BindingItems.Add(bindingItem);
                                            }
                                        }
                                        else if (list is Dictionary<string, object>)
                                        {
                                            ((Dictionary<string, object>)list).Add(value, text);
                                            if (null != binder && !String.IsNullOrEmpty(pull))
                                            {
                                                IBindingItem bindingItem = binder.NewBindingItemInstance();
                                                bindingItem.Source = item.Data;
                                                bindingItem.SourceProperty = pull;
                                                bindingItem.Target = list;
                                                bindingItem.TargetProperty = value;
                                                bindingItem.Expression = expression;
                                                binder.BindingItems.Add(bindingItem);
                                            }
                                        }
                                    }
                                }
                            }
                            if (controlPropertyElement.Attributes.ContainsKey("property"))
                            {
                                if (container.Page != null && null != binder)
                                {
                                    IBindingItem bindingItem = binder.NewBindingItemInstance();
                                    bindingItem.Source = WebPartManager.GetCurrentWebPartManager(container.Page);
                                    bindingItem.SourceProperty = "WebParts." + controlPropertyElement.GetAttributeReference("property").Value.ToString();
                                    bindingItem.Target = cellControl;
                                    bindingItem.TargetProperty = propertyName;
                                    if (string.IsNullOrEmpty(cellControlName) || propertyName != this.KnownTypes[cellControlName].ReadOnlyProperty)
                                        bindingItem.DefaultValue = defaultValue;
                                    bindingItem.Expression = expression;
                                    binder.BindingItems.Add(bindingItem);
                                }
                            }
                            if (controlPropertyElement.Attributes.ContainsKey("pull"))
                            {
                                string pull = controlPropertyElement.GetAttributeReference("pull").Value.ToString();
                                if (binder != null && null != item)
                                {
                                    IBindingItem bindingItem = binder.NewBindingItemInstance();
                                    bindingItem.Source = item.Data;
                                    bindingItem.SourceProperty = pull;
                                    bindingItem.Target = cellControl;
                                    bindingItem.TargetProperty = propertyName;
                                    if (string.IsNullOrEmpty(cellControlName) || propertyName != this.KnownTypes[cellControlName].ReadOnlyProperty)
                                        bindingItem.DefaultValue = defaultValue;
                                    bindingItem.Expression = expression;
                                    binder.BindingItems.Add(bindingItem);
                                    if (item.InvalidMember == bindingItem.SourceProperty)
                                        container.ApplyStyle(invalidStyle);
                                }
                                if (this.IsDesignEnabled && propertyName == this.KnownTypes[cellControlName].WatermarkProperty)
                                {
                                     // StyleTextBox has its own Watermark feature
                                    if (typeof(StyledTextBox).IsInstanceOfType(cellControl))
                                    {
                                        ReflectionServices.SetValue(cellControl, "Watermark", pull);
                                    }
                                    else
                                        container.Attributes.Add("watermark", pull);
                                }
                            }
                        }
                    }
                    result = cellControl;
                }
            }
            return result;
        }
开发者ID:t1b1c,项目名称:lwas,代码行数:101,代码来源:ControlFactory.cs

示例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);
		}
开发者ID:Profit0004,项目名称:mono,代码行数:28,代码来源:RepeatInfo.cs

示例3: RenderStyle

 private void RenderStyle(HtmlTextWriter writer, WebControl control, string className, MenuItemStyle style, bool applyInlineBorder)
 {
     if (!string.IsNullOrEmpty(className))
     {
         control.CssClass = className;
         if (applyInlineBorder)
         {
             writer.AddStyleAttribute(HtmlTextWriterStyle.BorderStyle, "none");
             writer.AddStyleAttribute(HtmlTextWriterStyle.FontSize, "1em");
         }
     }
     else if (style != null)
     {
         control.ApplyStyle(style);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:16,代码来源:MenuAdapter.cs

示例4: RenderVerbControl

 protected virtual void RenderVerbControl(HtmlTextWriter writer, WebControl control)
 {
     control.ApplyStyle(base.Zone.TitleBarVerbStyle);
     control.Page = base.WebPartManager.Page;
     control.RenderControl(writer);
 }
开发者ID:t1b1c,项目名称:lwas,代码行数:6,代码来源:BaseChrome.cs

示例5: 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)
//.........这里部分代码省略.........
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:101,代码来源:RepeatInfo.cs

示例6: RenderStyle

 private void RenderStyle(HtmlTextWriter writer, WebControl control, string className, MenuItemStyle style, bool applyInlineBorder) {
     if (!String.IsNullOrEmpty(className)) {
         control.CssClass = className;
         if (applyInlineBorder) {
             // Add inline style to force the border to none to override any CssClass (VSWhidbey 336610)
             writer.AddStyleAttribute(HtmlTextWriterStyle.BorderStyle, "none");
             // And an inline font-size of 1em to avoid squaring relative font sizes by applying them twice
             writer.AddStyleAttribute(HtmlTextWriterStyle.FontSize, "1em");
         }
     }
     else if (style != null) {
         control.ApplyStyle(style);
     }
 }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:14,代码来源:MenuAdapter.cs

示例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)
                {
//.........这里部分代码省略.........
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:101,代码来源:RepeatInfo.cs


注:本文中的System.Web.UI.WebControls.WebControl.ApplyStyle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。