避免在自定义控件中使用默认的Web控件属性 [英] Avoid default web control property in custom control
本文介绍了避免在自定义控件中使用默认的Web控件属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好朋友.
我正在开发一个自定义控件.我不希望默认的Web控件属性应该在我的自定义控件中.
例如
hello friends.
I am developing one custom control. I dont want default web control property should be in my custom control.
For example
public class Ieditor : WebControl
{.... }
当将此控件放在页面中时,您将看到默认的Web控件属性,例如Font,Border,Width,Height....我只想显示在类中定义的那些属性.
谢谢
Imrnakhan
When you put this control in the page, you will see default web control property such as Font,Border,Width,Height.... I want to show only those properties that I define in my class.
Thanks
Imrnakhan
推荐答案
我不太了解为什么要这么做,但是这里有一个示例(针对可见属性):
I don''t really understand why would you want to do this, but here''s an example how to do it (for property Visible):
[Browsable(false)]
public new bool Visible
{
get { return base.Visible; }
set { base.Visible = value; }
}
我不想为所有默认的Web控件属性编写代码.
我认为您误会了我的要求.
假设我在类中定义了三个属性,那么对于控件来说只有三个属性可见,其他默认的Web控件属性应该是隐藏或不可见.
问候
Imrankhan
I dont want to write a code for all default web control property.
I think you misunderstand my requirement.
Suppose, I have three property defined in class then only three properties will be visible for control, other default web control proeprty should be hide or invisible.
Regard
Imrankhan
我认为这是不可能的,因为除非您在公共属性上定义[Browsable(false)]属性,否则Visual Studio会显示所有公共属性.如果要将自己的属性与默认属性分开,则可以使用Category属性对属性进行分组:
I think this is not possible, because Visual Studio shows all public properties unless you define the [Browsable(false)] attribute on them. If you want to separate your own properties from the default ones, you could group your properties with the Category attribute:
[Category("MyOwnProperties")]
这篇关于避免在自定义控件中使用默认的Web控件属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文