properties.aspx 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <%@ Page Language="C#" AutoEventWireup="True" %>
  2. <body>
  3. <h3>CustomValidator render tests</h3>
  4. <form runat="server">
  5. <asp:TextBox id="TextBox1"
  6. runat="server"/>
  7. <asp:CustomValidator id="CV_noattributes"
  8. ControlToValidate="TextBox1"
  9. runat="server"/>
  10. <!-- this control should render as a single &nbsp;
  11. unfortunately there's no way to test this except
  12. through looking at the source, so we just test that the
  13. control doesn't show up in the resulting html. -->
  14. <asp:CustomValidator id="CV_static_downlevel"
  15. ControlToValidate="TextBox1"
  16. Display="Static"
  17. ErrorMessage="Your value isn't within min/max"
  18. EnableClientScript="False"
  19. runat="server"/>
  20. <!-- a dynamic uplevel validator. -->
  21. <asp:CustomValidator id="CV_dynamic_uplevel"
  22. ControlToValidate="TextBox1"
  23. Display="dynamic"
  24. ClientValidationFunction="myClientValidationFunction"
  25. ErrorMessage="Your value isn't 'Chris Toshok'"
  26. runat="server"/>
  27. <asp:Button id="submit" text="Submit"/>
  28. </form>
  29. <script Language="JavaScript">
  30. var TestFixture = {
  31. CV_noattributes : function () {
  32. JSUnit_BindElement ("CV_noattributes");
  33. Assert.NotNull ("JSUnit_GetElement ()", "exists");
  34. Assert.AttributeHasValue ("TextBox1", "controltovalidate", "controltovalidate");
  35. Assert.IsNull ("JSUnit_GetAttribute ('clientvalidationfunction')", "clientvalidationfunction");
  36. Assert.IsFunction ("JSUnit_GetAttribute ('evaluationfunction')", "evaluationfunction");
  37. Assert.AreEqualCase ("red", "JSUnit_GetAttribute ('style')['color']", "color style");
  38. Assert.AreEqualCase ("hidden", "JSUnit_GetAttribute ('style')['visibility']", "visibility style");
  39. },
  40. CV_static_downlevel: function () {
  41. JSUnit_BindElement ("CV_static_downlevel");
  42. Assert.IsNull ("JSUnit_GetElement ()", "does not exist");
  43. },
  44. CV_dynamic_uplevel: function () {
  45. JSUnit_BindElement ("CV_dynamic_uplevel");
  46. Assert.NotNull ("JSUnit_GetElement ()", "exists");
  47. Assert.AttributeHasValue ("TextBox1", "controltovalidate", "controltovalidate");
  48. Assert.AreEqual ("myClientValidationFunction", "JSUnit_GetAttribute ('clientvalidationfunction')", "clientvalidationfunction");
  49. Assert.IsFunction ("JSUnit_GetAttribute ('evaluationfunction')", "evaluationfunction");
  50. Assert.AttributeHasValue ("Dynamic", "display", "display");
  51. Assert.AttributeHasValue ("Your value isn't 'Chris Toshok'", "errormessage", "errormessage");
  52. Assert.AreEqualCase ("red", "JSUnit_GetAttribute ('style')['color']", "color style");
  53. Assert.AreEqualCase ("none", "JSUnit_GetAttribute ('style')['display']", "display style");
  54. Assert.AreEqual ("Your value isn't 'Chris Toshok'", "JSUnit_GetElement ().innerHTML", "innerHTML");
  55. }
  56. };
  57. </script>
  58. </body>
  59. </html>