Click here to Skip to main content
15,888,803 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Everyone,
I create MyCustomTextBoxControl.ascx that type is Web User Control. Then I add a textbox to my control.

After that i add MyCustomTextBoxControl.ascx to my page. Only shows control properties when i select my control and i look at the properties windows in designing time. I want to seeing textbox properties inside of the my control's property. (not one of them, all of them)

How can i do this?
Thanks

Example;
C#
public partial class MyCustomTextboxControl : System.Web.UI.UserControl
 {
     [Browsable(true)]
     public TextBox MyTextBox
     {
         get
         {
             return TextBox1;
         }
         set
         {
             TextBox1 = value;
         }
     }
 }


But this is invalid code.
Posted

1 solution

Why are you doing that?
Why not derive from a TextBox directly - that way you get the properties of the textbox shown as part of your control.
Unless you are adding other controls within the context of your control, that is the simplest solution.

And you really, really, shouldn't expose your internal controls in the way you suggest - it locks the design of your control to containing a textbox - you can't make changes without considering their affect on anything that might use your control. Expose only what you need to - don't expose whole controls.
 
Share this answer
 
Comments
Ibrahim Uylas 21-Jan-13 7:20am    
I do some customization. These are like;
-adding some component to my control like Ajax Extender(behind of code)
-adding new properties. They are used in load.
and something like this.

So I don't want add a property my custom control and my textbox. Only i add a custom property to textbox and i want to seeing it in the control properties.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900