To lighten the mood in my office, I came up with fun C# ASP.NET page to randomly display lotto numbers. It's configured for the Cali lotto format but you can easily modify it for whatever state your in. Enjoy.
using System;
using System.Web;
using System.Text;
public partial class numbers : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void GetLottoNumbers(object sender, EventArgs e)
{
ArrayList arlNum = new ArrayList();
Random RandomClass = new Random();
while (arlNum.Count < 5)
{
int g = RandomClass.Next(1, 56);
if (!arlNum.Contains(g))
{
arlNum.Add(g);
}
}
arlNum.Sort();
pnlNum.Visible = true;
lblN1.Text = arlNum[0].ToString();
lblN2.Text = arlNum[1].ToString();
lblN3.Text = arlNum[2].ToString();
lblN4.Text = arlNum[3].ToString();
lblN5.Text = arlNum[4].ToString();
lblN6.Text = RandomClass.Next(1, 46).ToString();
btnNumbers.Text = "Get Another Set";
}
}
-----------------------Portion of numbers.aspx------------------------------
<h2>IT Retirement Numbers</h2>
<hr />
<p><strong>Would you like to see some IT retirement numbers?</strong></p>
<asp:Button ID="btnNumbers" runat="server" Text="Get Numbers" OnClick="GetLottoNumbers" />
<asp:Panel ID="pnlNum" runat="server" Visible="false">
<br />
Here you go...
<asp:Label ID="lblN1" runat="server" Width="20" />
<asp:Label ID="lblN2" runat="server" Width="20" />
<asp:Label ID="lblN3" runat="server" Width="20" />
<asp:Label ID="lblN4" runat="server" Width="20" />
<asp:Label ID="lblN5" runat="server" Width="20" />
and mega number
<asp:Label ID="lblN6" runat="server" Width="20" />
</asp:Panel>
No comments:
Post a Comment