How to Change Button width Programmatically

 1.File->New->Website->(left side select visual c#) ASP.NET Web Site->ok

2.Now You will see a Default.aspx page.
To create your own page->click on dropdown list below Edit->click Add new item->Select Web Form->click Add

3. Click Split(to see Design and code View simultaniously)->From ToolBox Drag and Drop a Label to Design window->Right click on label->select properties->(look for text property) change text property from label to "Button Width Example".

4.Drag and drop a button below label->Right click on Button->select properties->change text property from Button to "Width 300.Your window should look like this.

5.Double click on the Button(or Right click the Button select view code)->then write this code

protected void Button1_Click(object sender, EventArgs e)
    {
        Button1.Width = 300;
    }
6.click F5->ok.
Before Button Click


After Button Click









 If you have any problem with this article just leave a comment.

No comments:

Post a Comment