disabledcontrols.aspx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <%@ page language="C#"%>
  2. <script runat="server">
  3. void Page_Load(Object sender, EventArgs e)
  4. {
  5. if (IsPostBack)
  6. {
  7. // the second time through, print out the submitted form info
  8. foreach (string key in Page.Request.Form.AllKeys) {
  9. Response.Write (String.Format ("{0}: {1}<br/>", key, Page.Request.Form[key]));
  10. }
  11. }
  12. else
  13. {
  14. // The first time the page loads, set the values
  15. // of the HtmlInputText and HtmlInputCheckBox controls.
  16. InputText1.Value = "Test";
  17. InputCheckBox1.Checked = true;
  18. }
  19. }
  20. </script>
  21. <html>
  22. <head id="Head1"
  23. runat="server">
  24. <title>HtmlForm SubmitDisabledControls Property Example</title>
  25. </head>
  26. <body>
  27. <form id="form1"
  28. submitdisabledcontrols="true"
  29. runat="server">
  30. <h3>HtmlForm SubmitDisabledControls Property Example</h3>
  31. <input id="InputText1"
  32. name="InputText1"
  33. type="text"
  34. runat="server" />
  35. <input id="InputCheckBox1"
  36. name="InputCheckBox1"
  37. type="Checkbox"
  38. runat="server" />
  39. <asp:Button id="PostBackButton"
  40. text="Post back"
  41. runat="server" />
  42. </form>
  43. </body>
  44. </html>
  45. <script Language="javascript">
  46. // Disable the HTML controls on the form.
  47. document.getElementById('InputText1').disabled = true;
  48. document.getElementById('InputCheckBox1').disabled = true;
  49. </script>