G
Guest
Hi.
I tried to design a custom web control which can flexibly and
dynamicly let the control user ,for example the web page developer, customize
its layout codes.This control derives from System.Web.UI.Control,and for my
purpose,I define a delegate property in the control's class definition, so
control user can define his(or her) method out of the class definition and
add his(or her) method to the delegate chain. I also override the Render
method of System.Web.UI.Control to call this delegate,so in the Rendering
stage, customized rendering logics can be implemented.
This is the question. Since I define the delegate as property(also
accompanid with a private field with the same name except the first letter
lowcasing,according to the Camel style) ,how can I deal with the "+=" and
"="? I mean maybe I have two choices:
1.Use "=" in the "set" block in property definition and tell control
users to use "+=" when they use the property in their web pages.
In class definition-->property definition:
set{
delegateName = value;
}
In web page before "Rendering" stage:
controlName.DelegateName += CustomRenderingMethod;
2.Use "+=" in the "set" block and "=" in web pages.
In class definition-->property definition:
set{
delegateName += value;
}
In web page before "Rendering" stage:
controlName.DelegateName = CustomRenderingMethod;
By the way,I think both "=" or both "+=" is either not reasonable. I
wonder what is the correct way.
Appretiate for any help.
I tried to design a custom web control which can flexibly and
dynamicly let the control user ,for example the web page developer, customize
its layout codes.This control derives from System.Web.UI.Control,and for my
purpose,I define a delegate property in the control's class definition, so
control user can define his(or her) method out of the class definition and
add his(or her) method to the delegate chain. I also override the Render
method of System.Web.UI.Control to call this delegate,so in the Rendering
stage, customized rendering logics can be implemented.
This is the question. Since I define the delegate as property(also
accompanid with a private field with the same name except the first letter
lowcasing,according to the Camel style) ,how can I deal with the "+=" and
"="? I mean maybe I have two choices:
1.Use "=" in the "set" block in property definition and tell control
users to use "+=" when they use the property in their web pages.
In class definition-->property definition:
set{
delegateName = value;
}
In web page before "Rendering" stage:
controlName.DelegateName += CustomRenderingMethod;
2.Use "+=" in the "set" block and "=" in web pages.
In class definition-->property definition:
set{
delegateName += value;
}
In web page before "Rendering" stage:
controlName.DelegateName = CustomRenderingMethod;
By the way,I think both "=" or both "+=" is either not reasonable. I
wonder what is the correct way.
Appretiate for any help.