473,395 Members | 2,437 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Create a random code and store it in the Session object

hii i hav a problem with thsi code
check it once
Expand|Select|Wrap|Line Numbers
  1. if (!this.IsPostBack)
  2.  
  3. // Create a random code and store it in the Session object.
  4.  
  5. this.Session["CaptchaImageText"] = GenerateRandomCode();
  6.  
  7. else
  8.  
  9. {
  10.  
  11. // On a postback, check the user input.
  12.  
  13. if (this.CodeNumberTextBox.Text ==
  14.  
  15. this.Session["CaptchaImageText"].ToString())
  16.  
  17. {
  18.  
  19. // Display an informational message.
  20.  
  21. this.MessageLabel.CssClass = "info";
  22.  
  23. this.MessageLabel.Text = "Correct!";
  24.  
  25. }
  26.  
  27. else
  28.  
  29. {
  30.  
  31. //Display an error message.
  32.  
  33. this.MessageLabel.CssClass = "error";
  34.  
  35. this.MessageLabel.Text = "ERROR: Incorrect, try again.";
  36.  
  37. // Clear the input and create a new random code.
  38.  
  39. this.CodeNumberTextBox.Text = "";
  40.  
  41. this.Session["CaptchaImageText"] = GenerateRandomCode();
  42.  
  43. }
  44.  
  45. }
  46.  
  47. }
the second else is directly executing without anywrong entry of text
so please tell how to correct thsi code
Aug 27 '08 #1
2 1308
kenobewan
4,871 Expert 4TB
Suggest using try catch to debug errors...
Aug 27 '08 #2
cloud255
427 Expert 256MB
Try inserting a break point on the second if statement to make sure that the values are what they should be, it would appear to me that one of those values gets an unexpected value and thus the 2 are never equal
Aug 27 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Golf Nut | last post by:
hello all! I would like to create a session class which would transparently handle sessions as well as serialize, encode and compute an md5 hash of all $_REQUEST information. This would...
4
by: Jefferis NoSpamme | last post by:
I have a query that is showing new items in a store based upon their inventory date. The problem with my Random order sort is that when the "next" link is pressed, the random function is called...
10
by: Johnny Snead | last post by:
Hey guys, Need help with this random sort algorithm private void cmdQuestion_Click(object sender, System.EventArgs e) { Random rnd = new Random(); //initialize rnd to new random object...
4
by: MattC | last post by:
Gents, I have had to persist the viewstate into the Session object, however once this was done the W3WP process' memory ramped right up and used 300MB of VM. Below is my code, can anyone see...
5
by: Logickle | last post by:
Hi, all. I'm working on an application which requires communicating session info between separate web apps running on the same web server. The out of process server method sounded ideal, and...
2
by: Markus Prediger | last post by:
Hi NG, I have an asp.net project that uses an vb6 com object for some database-manipulation (I cannot rewrite it in .net, sorry, its not my decision). I want it to be instanciated seperately...
1
by: rushikesh.joshi | last post by:
Hi All, I want some charting functionality in my ASP.NET application. I want to show a multiple bar on my web page. It's based on down time of different servers. like server1: down betn 4 AM...
1
by: Jim in Arizona | last post by:
I created a public application based variable not within any procedure, like so: Partial Class lobbytimes_lobbytimes Inherits System.Web.UI.Page Public BackgroundImage As String Protected...
1
by: Dave | last post by:
I have multiple forms that will create an object. Basically a energy efficiency measure object. The measure object will have a couple of required properties set but after that it can have 10-20...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.