ClientVerification.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Web.UI;
  5. using System.Web.UI.HtmlControls;
  6. using System.Web.UI.WebControls;
  7. using System.Resources;
  8. namespace LocalizingScriptResources
  9. {
  10. public class ClientVerification : Control
  11. {
  12. private Button _button;
  13. private Label _firstLabel;
  14. private Label _secondLabel;
  15. private TextBox _answer;
  16. private int _firstInt;
  17. private int _secondInt;
  18. protected override void CreateChildControls()
  19. {
  20. Random random = new Random();
  21. _firstInt = random.Next(0, 20);
  22. _secondInt = random.Next(0, 20);
  23. ResourceManager rm = new ResourceManager("SystemWebExtensionsAUT.LocalizingClientResourcesWalkthrough.VerificationResources", this.GetType().Assembly);
  24. Controls.Clear();
  25. _firstLabel = new Label();
  26. _firstLabel.ID = "firstNumber";
  27. _firstLabel.Text = _firstInt.ToString();
  28. _secondLabel = new Label();
  29. _secondLabel.ID = "secondNumber";
  30. _secondLabel.Text = _secondInt.ToString();
  31. _answer = new TextBox();
  32. _answer.ID = "userAnswer";
  33. _button = new Button();
  34. _button.ID = "Button";
  35. _button.Text = rm.GetString("Verify");
  36. _button.OnClientClick = "return CheckAnswer();";
  37. Controls.Add(_firstLabel);
  38. Controls.Add(new LiteralControl(" + "));
  39. Controls.Add(_secondLabel);
  40. Controls.Add(new LiteralControl(" = "));
  41. Controls.Add(_answer);
  42. Controls.Add(_button);
  43. }
  44. }
  45. }