asp:Button action to change the asp:Label and generate random number (VB.net) : Label « Asp Control « ASP.Net






asp:Button action to change the asp:Label and generate random number (VB.net)

<%@ Page Language="VB" %>
<script runat="server">
    Sub Button1_Click(sender As Object, e As EventArgs)
      Label3.Visible = False
      Label1.Text = Int(Rnd() * 6) + 1
      Label2.Text = Int(Rnd() * 6) + 1
      If Label1.Text = "1" And Label2.Text = "1" Then
    
        Label5.Text = Label4.Text
        If CInt(Label5.Text) > CInt(Label6.Text) Then
          Label6.Text = label5.Text
        End If
    
        Label4.Text = 0
        Label3.Visible = True
      Else
        Label4.Text = CInt(Label4.Text) + _
                      CInt(Label1.Text) + CInt(Label2.Text)
      End If
    End Sub
    
    Sub Button2_Click(sender As Object, e As EventArgs)
    
      Label6.Text = 0
    
    End Sub

</script>
<html>
<head>
</head>
<body>
    <form runat="server">
        <h1>Snake Eyes! 
        </h1>
        <p>
            Keep going, but don't get two 1's... 
        </p>
        <p>
            <asp:Label id="Label1" runat="server" BorderStyle="Solid" Font-Names="Verdana" Font-Size="X-Large" Height="44px">0</asp:Label>
            <asp:Label id="Label2" runat="server" BorderStyle="Solid" Font-Names="Verdana" Font-Size="X-Large" Height="44px">0</asp:Label>
        </p>
        <p>
            <asp:Label id="Label3" runat="server" Visible="False">Ooops, you did it again :(</asp:Label>
        </p>
        <p>
            <asp:Button id="Button1" onclick="Button1_Click" runat="server" Text="Hit me baby one more time..."></asp:Button>
        </p>
        <p>
            <asp:Label id="Label4" runat="server" Font-Names="Verdana" Font-Size="X-Large" ForeColor="Red">0</asp:Label>
        </p>
        <p>
            Last Score:<asp:Label id="Label5" runat="server" Font-Names="Verdana" Font-Size="X-Large" ForeColor="Red">0</asp:Label>
        </p>
        <p>
            High Score: 
            <asp:Label id="Label6" runat="server" Font-Names="Verdana" Font-Size="X-Large" ForeColor="Red">0</asp:Label>
        </p>
        <p>
            <asp:Button id="Button2" onclick="Button2_Click" runat="server" Text="Reset High Scores"></asp:Button>
        </p>
    </form>
</body>
</html>

           
       








Related examples in the same category

1.asp:Label background color (VB.net)
2.Set Label style (VB.net)
3.asp:label: border, font and background color
4.BorderWidth, BorderColor, Font-Size, Font-Name, ForeColor, BackColor , ToolTip, Visible for asp:Label (VB.net)
5.Do a simple calculation and set value to asp:Label (VB.net)
6.Set static asp:Label value
7.Set asp:Label text (VB.net)
8.Set color and font for an asp:Label (VB.net)
9.Your First Page: display a Text runat Server (VB.net)
10.Change Label to be visible (C#)
11.Display all page event in asp label (C#)
12.Change asp label text in asp button action (C#)
13.Assign current time to asp label (C#)
14.Define function to change Label Font to Italic (C#)
15.Set Label background color (C#)
16.Boolean value toggle: label Visible (C#)
17.Set Asp Label Text during page load (C#)
18.Asp server Label: display server time (C#)
19.Label's color