0

I would like to create a single control containing a TextBox and a Button but I have never created a custom control before and I am not sure how to do it, this is what I have done :

namespace CustomControls
{
    public partial class TBP : TextBox
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        public TBP()
        {
            this.Controls.Add(_Button);
        }

        private Button _Button = new Button();
    }
}
3
  • 1
    I guess you need UserControl instead of Custom Control here, but of course it depends on your requirement. Do you want to reuse it multiple projects? Check Recommendations by Microsoft first. Commented Jan 11, 2016 at 13:24
  • Will I have to redefine all the methods and properties of a textbox/button for my custom control ? Commented Jan 11, 2016 at 13:28
  • You are creating the textbox & checkbox dynamically so I would not say redefine rather you will have to define them all. Check for basic tutorials for both and please keep in mind Custom control is difficult as compared to User Control. Commented Jan 11, 2016 at 13:31

1 Answer 1

1

Creating User Control

Using a User Control

Events in User Control

Take a look on this 3 articles and you will be able to work with Controls due to your request.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the links.
@Stan you will spend maximum 15 minutes to learn, how to use that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.