Random number generate for security number in label

Posted by Mittaikariss under ASP.NET category on | Points: 40 | Views : 3241
page load
if (TextBox3.Text == "")
Random rx = new Random();

Session["random"] = rx.Next(1000, 100000);
scode.Text = Session["random"].ToString();
then button click check the textbox number equal to random no

if (TextBox3.Text == Session["random"].ToString())

Invom Technology

Comments or Responses

Posted by: T.saravanan on: 9/4/2011 Level:Silver | Status: [Member] [MVP] | Points: 10
Hi Mittai Kariss,

In your code what is 'scode'.

Kindly post your code inside the code tag.If you are new user means just select your code from content contol and click the code tag above of the content control.

Posted by: Mittaikariss on: 9/12/2011 Level:Bronze | Status: [Member] | Points: 10
scode means label name....its use for print random no
Posted by: T.saravanan on: 9/12/2011 Level:Silver | Status: [Member] [MVP] | Points: 10
Ok. Kindly post your code inside the code tag.
Posted by: Pervej on: 9/24/2011 Level:Starter | Status: [Member] | Points: 10
Posted by: Biswarup90 on: 11/23/2011 Level:Starter | Status: [Member] | Points: 10
IN VB Code

<%@ 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
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

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

Login to post response