How to turn off unnecessary functions of base class in ASP.NET
This article mainly shows you "how to close the unnecessary functions of the base class in ASP.NET", the content is simple and clear, and I hope it can help you solve your doubts. Let me lead you to study and learn this article "how to turn off unnecessary functions of the base class in ASP.NET".
Here are two of them:
1. Close the container
The Control class has the Controls collection property, that is, the control that inherits the Control class is a container control, and the asp.net control has a built-in PlaceHolder control, which only inherits from the Control class and does nothing. But all controls inherit from the Control class. Like a label control, it can still be used as a container.
Label1.Controls.add (control)
Some controls do not need this function, such as Literal controls, which only output plain text and are not allowed to add child controls.
Quite simply, override the CreateControlCollection method to return an empty collection of EmptyControlCollection
Protected override ControlCollection CreateControlCollection () {return new EmptyControlCollection (this);}
For example, the SqlDataSourceControl control inherits from the DataSourceControl,DataSourceControl class and inherits from the Control class. DataSourceControl does not need to render things and naturally does not need styles, so properties such as SkinID,EnableTheming do not need to be used. You can also disable some common properties like the WebControl class with the new keyword and some metadata. Sometimes you really don't need these things, or you can use these attributes for subtags.
/ * * / [Bindable (false), Browsable (false), EditorBrowsable (EditorBrowsableState.Never)] new public System.Drawing.Color BorderColor {get {return new System.Drawing.Color ();}} these are all the contents of the article "how to turn off unnecessary functions of the base class in ASP.NET". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!