Stan
Stan

Reputation: 411

ASP.NET TextBox and Button in the same control

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();
    }
}

Upvotes: 0

Views: 210

Answers (1)

Khazratbek
Khazratbek

Reputation: 1656

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.

Upvotes: 1

Related Questions