【问题标题】:JQuery Dialog with Checkbox and Submit button in C#C# 中带有复选框和提交按钮的 JQuery 对话框
【发布时间】:2013-03-30 15:14:05
【问题描述】:

基本上我有一个 JQuery UI 对话框,但我需要在其中集成一个复选框和一个提交按钮。单击提交按钮关闭对话框后,我需要选中该复选框。这与条款和条件的概念相同。

有人愿意分享如何做/最好的方法吗?一直在四处寻找,但没有找到任何靠近的地方。

谢谢。

<script type="text/javascript">
$(function() {
$("#dialog").dialog({
      autoOpen: true,
      closeOnEscape: false,
      resizable: false,
      draggable: false,
      height: 700,
      width: 700,
      modal: true,
      show: { effect: "fade", duration: 1000 }
      });
  });
  $(function() {
      $("#dialog").dialog({
          buttons: {
          Confirm: function() {
                  $(this).dialog("close");
              }
          }
      });
  });

<asp:CheckBox ID="CheckBox1" runat="server" />
  <asp:Button ID="Button2" runat="server" Text="Button" />

【问题讨论】:

  • 你能发布你的代码吗?
  • 按要求添加代码 - 我不确定如何进行验证方面

标签: c# javascript jquery asp.net validation


【解决方案1】:

您可以先禁用提交按钮,然后在选中复选框时切换是否启用:

$('#Button2').attr('disabled', true);

$("#dialog #CheckBox1").change(function() {
  $('#Button2').attr('disabled',!this.checked);
});

另外,我对 jQuery 对话框为您插入按钮的能力不是很熟悉,因为我使用的所有 HTML 都是由我们的设计人员预先创建并使用自定义绑定框架,但看起来您也使用 pre - 生成的 asp.net HTML。如果,那么我认为您不会使用 jQuery 对话框来生成按钮。相反,您将拥有如下代码:

$('#Button2').click(function() {
  // Submit code.  Possibly $.post() and $("#dialog").dialog('close')
  // or triggering the webform's postback.
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多