1. when I open it is green
2. when I click a button it is blue
3. when I click the same button it is red
alternate 2 and 3
I have written this code but it does not work. Which thing I am mistaking?
Expand|Select|Wrap|Line Numbers
- <%@ Page Language="C#"%>
- <script runat="server">
- bool T=false;
- int a=1;
- protected void Page_Load(Object Src, EventArgs E)
- {
- Sfondo.Attributes.Add("bgcolor", "#00ff00");
- }
- void Cambia_Sfondo(Object Src, EventArgs E)
- {
- T=!T;
- if (T)
- {
- Sfondo.Attributes.Add("bgcolor", "#0000ff");
- }
- else
- {
- Sfondo.Attributes.Add("bgcolor", "#ff0000");
- }
- a++;
- }
- </script>
- <html>
- <body id="Sfondo" runat="server">
- <form runat="server">
- <asp:Button OnClick="Cambia_Sfondo" Text="Cambia Sfondo" Height="20"
- Width="80" runat="server"/>
- <br><%Response.Write("A= " + a);%>
- </form>
- </body>
- </html>