Shield .NET Customize Properties in Development Components

xiaoxiao2021-03-06  48

Today, I saw a message from a netizen: I would like to ask the brothers, and how to inherit the existing components in Microsoft .NET Framework, how to block some attributes, is the new component does not provide inheritance, such as inheriting PANEL Newly written EPANEL, how to block the backcolor for the PANEL's attribute? ? This problem workaround is as follows: Step 1: Define the design of the service in your control class [Designer (msplus.web.ui.design.webcontrols.buttondesigner)]

[Description

"

Msplus WebControl Button

"

)] [Designer

Typeof

(Msplus.web.ui.design.webcontrols.buttondesigner)]]]

public

SeaD

Class

Button: MsplusWebControl, iPostBackeventhandler

{}

Step 2: Add a design-time service class, this class inherits system.web.ui.design.ControlDesigner Step 3: Rewote the postfilterProperties () method, allowing the designer to change or remove items from the attribute exposed by TypedScriptor .

/ ** /

/ ** * namespace: MSPlus.Web.UI.Design.WebControls * Class: ButtonDesigner * * Author: Mack.Z * Completion Date: 2003-12-21 * Copyright Information: MSLULU (2000.10.10) ** /

Using

System;

Using

System.componentmodel;

Using

System.componentmodel.design;

Using

System.collections;

Namespace

Msplus.web.ui.design.webcontrols

{/ ** ////

/// ButtonDesigner's summary description. /// public class ButtonDesigner: System.Web.UI.Design.ControlDesigner {public ButtonDesigner () {// // TODO: Add constructor logic here //} protected override void PostFilterProperties (IDictionary Properties) {Properties.Remove ( "Height"); Properties.Remove ( "BackColor"); Properties.Remove ( "BorderWidth"); Properties.Remove ( "Font"); Properties.Remove ( "ForeColor"); Properties.Remove ( "Tabindex"); Properties.Remove ("Tooltip"); Properties.Remove ("enabled"); Properties.Remove ("enableViewState");}}} If you have a problem with your control, you can also be on my homepage Leave a message.

Author Blog:

http://blog.9cbs.net/mack_zhu/

转载请注明原文地址:https://www.9cbs.com/read-117320.html

New Post(0)