ASP.NET自定义控件从入门到精通42011-04-17 博客园 hongbo05213 状态管理和Style类3.3 开发自定义的Style类在上一节中,我们讲到了Style类的属性和方法。但是Style类本身并没有提供全面的CSS 样式属性的支持。我们需要继承Style类或Style类的子类,才能支持我们想要的CSS样式属性 。首先我们分析我们现在所写的Register控件的主要布局格式即Table布局,那么我们只需 要继承与Style类的子类TableStyle类就可以获取Table的样式控制。首先我们先来添加一个新类,类名为:RegisterControleStyle。首先为 RegisterControleStyle类提供无参构造函数RegisterControleStyle()。然后在提供以下代 码中的构造函数:using System; using System.Collections.Generic; using System.Text; using System.ComponentModel; using System.Text; using System.Web; using System.Web.UI; using System.Web.UI.WebControls;
namespace RegisterControl { public enum BackImageRepeat { Repeat,RepeatX,RepeatY,NoRepeat,Inherit }
public class RegisterControlStyle : TableStyle { public RegisterControlStyle() { }
public RegisterControlStyle(StateBag viewState) : base(viewState) {