Go Back  HTML Forums - Free Webmaster Forums and Help Forums > WEBSITE DEVELOPMENT > Server Side Programming > ASP and ASP.NET
User Name:
Password:
 

Reply
Thread Tools   Display Modes
  View First Unread
 
Old 05-14-2009, 11:00 AM
  #1
Folken0007
Novice (Level 1)
 
Folken0007's Avatar
 
Join Date: Jun 2003
Location: En algun lugar de México
Posts: 5
iTrader: (0)
Folken0007 is on a distinguished road
how can i generate Random number C#

I want to generate a number and I want it appear on a asp:label. Also the number have to be between 1 to 99 (min. - max.)

That number will be added to a number generated in a captcha. I know how to generate a catpcha and added a number but not a ramdom one.

I hope that solution stop spambots

Last edited by Folken0007 : 05-14-2009 at 11:03 AM. Reason: i forgot something
Folken0007 is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 07-01-2009, 02:47 AM
  #2
GrillMonkey
Warrior (Level 8)
 
Join Date: Jun 2009
Posts: 71
iTrader: (0)
GrillMonkey is an unknown quantity at this point
Code:
Random rand = new Random();
    
mylabel.Text = rand.Next(1,99).ToString();
this is probably the easiest way.
GrillMonkey is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 07-17-2009, 02:28 PM
  #3
thewebhostingdi
Fighter (Level 4)
 
Join Date: Jun 2009
Posts: 33
iTrader: (0)
thewebhostingdi is an unknown quantity at this point
That will return the same number every page load, I think. I had implemented the same concept but it is returning the same numbers.

Code:
        Random r = new Random(1);
        int ans,n1,n2;
        n1 = r.Next(1,4);
        n1 = r.Next(1, 4);
        n1 = r.Next(1, 4);
        n2 = r.Next(4, 8);
        n2 = r.Next(4, 8);
        n2 = r.Next(4, 8);
        ans = n1 + n2;
        Label5.Text = "Please Answer: " + n1.ToString() + " + " + n2.ToString() + " = ";
thewebhostingdi is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 07-20-2009, 02:46 AM
  #4
GrillMonkey
Warrior (Level 8)
 
Join Date: Jun 2009
Posts: 71
iTrader: (0)
GrillMonkey is an unknown quantity at this point
No it wont.

You are correct that it's not random in the truest sense but it'll display a different number for each page load.
GrillMonkey is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote

Reply
KEEP TABS
SPONSORS
 
Boxedart



 
 


 
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
  
 
 
 



 
  POSTING RULES
 
 
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Thread Tools
Display Modes

Forum Jump

 

All times are GMT -5. The time now is 03:55 PM.

   

Mascot team created by Drawshop.com

Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.

Server Monitoring by ENIACmonitor 0.01
HTMLforums.com © Big Resources, Inc. Web Design by BoxedArt.com
vRewrite 1.5 beta SEOed URLs completed by Tech Help Forum and Chalo Na.