Tuesday, 29 July 2014

Change Label border color Programmatically in ASP.NET

Change Label border color Programmatically in ASP.NET
  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 Button1_Click(object sender, System.EventArgs e)
  5.     {
  6.         Label1.BorderColor = System.Drawing.Color.HotPink;
  7.     }
  8.     protected void Button2_Click(object sender, System.EventArgs e)
  9.     {
  10.         Label1.BorderColor = System.Drawing.Color.SpringGreen;
  11.     }
  12. </script>

  13. <html xmlns=“http://www.w3.org/1999/xhtml”>
  14. <head id=“Head1″ runat=“server”>
  15.     <title>How to set, change Label border color programmatically</title>
  16. </head>
  17. <body>
  18.     <form id=“form1″ runat=“server”>
  19.     <div>
  20.         <h2 style=“color:Navy”>Label Example: BorderColor</h2>
  21.         <asp:Label
  22.              ID=“Label1″
  23.              runat=“server”
  24.              Text=“Click any button for change border color.”
  25.              BorderWidth=“2″
  26.              >
  27.         </asp:Label>
  28.         <br /><br />
  29.         <asp:Button
  30.              ID=“Button1″
  31.              runat=“server”
  32.              ForeColor=“SlateBlue”
  33.              Text=“BorderColor HotPink”
  34.              OnClick=“Button1_Click”
  35.              Font-Bold=“true”
  36.              />
  37.         <asp:Button
  38.              ID=“Button2″
  39.              runat=“server”
  40.              Font-Bold=“true”
  41.              ForeColor=“SlateBlue”
  42.              Text=“BorderColor SpringGreen”
  43.              OnClick=“Button2_Click”
  44.              />
  45.     </div>
  46.     </form>
  47. </body>
  48. </html>



No comments:

Post a Comment