Tuesday, 29 July 2014

How to change asp.net Button width programmatically

How to set, change Button width programmatically:
  1. <%@ Page Language=“C#” %>

  2. <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

  3. <script runat=“server”>
  4.     protected void Button2_Click(object sender, System.EventArgs e)
  5.     {
  6.          Button1.Width = 200;
  7.     }
  8.     protected void Button3_Click(object sender, System.EventArgs e)
  9.     {
  10.         Button1.Width = 300;
  11.     }
  12. </script>

  13. <html xmlns=“http://www.w3.org/1999/xhtml”>
  14. <head id=“Head1″ runat=“server”>
  15.     <title>How to set, change Button width programmatically</title>
  16. </head>
  17. <body>
  18.     <form id=“form1″ runat=“server”>
  19.     <div>
  20.         <h2 style=“color:Red”>Button Example: Width</h2>
  21.         <asp:Button
  22.              ID=“Button1″
  23.              runat=“server”
  24.              Text=“Test Button Width”
  25.              ForeColor=“SaddleBrown”
  26.              Font-Bold=“true”
  27.              Height=“30″
  28.              />
  29.         <br /><br />
  30.         <asp:Button
  31.              ID=“Button2″
  32.              runat=“server”
  33.              Text=“Button Width 200″
  34.              OnClick=“Button2_Click”
  35.              />
  36.         <asp:Button
  37.              ID=“Button3″
  38.              runat=“server”
  39.              Text=“Button Width 300″
  40.              OnClick=“Button3_Click”
  41.              />
  42.     </div>
  43.     </form>
  44. </body>
  45. </html>



No comments:

Post a Comment