Change Button width programmatically
Button is an asp.net web server control which render a push button on web browser.
button server control have a built in property to set or change button width. button Width
property allow us to set or get the width of the button web server control.
Width property value type is System.Web.UI.WebControls.Unit. this unit represents the width of the button control. this property default value is Empty. we can set a numeric value to specify button width.
the following asp.net c# example code demonstrate us how can we set or change button server control's width programmatically.
Width property value type is System.Web.UI.WebControls.Unit. this unit represents the width of the button control. this property default value is Empty. we can set a numeric value to specify button width.
the following asp.net c# example code demonstrate us how can we set or change button server control's width programmatically.
ButtonWidth.aspx
<%@ Page Language="C#" %>
<!DOCTYPE html>
<script runat="server">
protected void Button2_Click(object sender, System.EventArgs e)
{
Button1.Width = 200;
}
protected void Button3_Click(object sender, System.EventArgs e)
{
Button1.Width = 300;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>How to set, change Button width programmatically</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:Red">Button Example: Width</h2>
<asp:Button
ID="Button1"
runat="server"
Text="Test Button Width"
ForeColor="SaddleBrown"
Font-Bold="true"
Height="30"
/>
<br /><br />
<asp:Button
ID="Button2"
runat="server"
Text="Button Width 200"
OnClick="Button2_Click"
/>
<asp:Button
ID="Button3"
runat="server"
Text="Button Width 300"
OnClick="Button3_Click"
/>
</div>
</form>
</body>
</html>


