在asp.net中弹出时,jQuery模态对话框被禁用(灰显)

时间:2015-09-10 21:05:32

标签: jquery asp.net

我有一个从代码后面调用的jquery模式对话框,当它弹出时,它只是被禁用,我可以选择或点击表单。这是我的代码

脚本:

    $(document).ready(function() {     
       $("#addrDialog").dialog({              
           modal: true,
           autoOpen: false,
           appendTo: "#form",
           resizable: false,
          draggable: false,
          closeOnEscape: false,
          width: "auto",
          show: "fade",
          hide: "drop",
          open: function () {
              $(".ui-dialog-titlebar-close").hide();                  
          },
          buttons: [{
              text: "Select",
              click: function () {
                  var value = " ";
                  storedIndex = " ";
                  var selected = $("[id*=lstCandidates] option:selected");
                  selected.each(function () {
                      value = $(this).val();
                      storedIndex = $(this).index();
                      $("#hIndex").val(storedIndex);
                  });
                  $(this).dialog("close");
              },
              style: "margin-right: 40px;"
          },
                    {
                        text: "Cancel",
                        click: function () {
                            $(this).dialog("close");                                
                        },
                        style: "margin-left:0px;"
                    }]
      })
     });

  function AddrDialog() {
      $(function () {
          $("#addrDialog").dialog("open");             
          return false;
      });
  }

这是我的页面:

     <div id="parentForm">
    <input type="hidden" id="hIndex" value="<%=strIndex%>" name="hIndex" />
    <input type="hidden" id="hdnBtnPostback" name="hdnBtnPostback" />

<div>
    <p>
        <asp:Label ID="lblStreet" runat="server" Text="Street Address:" AssociatedControlID="txtStreet"></asp:Label>
        <asp:TextBox ID="txtStreet" runat="server" MaxLength="50" Text="30 Rockefeller Plaza"></asp:TextBox>        
        <asp:Label ID="lblCity" runat="server" Text="City:" AssociatedControlID="txtCity"></asp:Label>
        <asp:TextBox ID="txtCity" runat="server"  MaxLength="20" Text="New York" ></asp:TextBox>       
         <asp:Label ID="lblState" runat="server"  Text="State:" AssociatedControlID="txtState"></asp:Label>
         <asp:TextBox ID="txtState" runat="server" Enabled="False" Text="NY" MaxLength="2"></asp:TextBox>        
        <asp:Label ID="lblZip5" runat="server" Text="10112" AssociatedControlID="txtZip5"></asp:Label>
        <asp:TextBox ID="txtZip5"  runat="server" MaxLength="5" ></asp:TextBox>        
        <asp:Label ID="lblZip4" runat="server" Text="-" AssociatedControlID="txtZip4"></asp:Label>
        <asp:TextBox ID="txtZip4" runat="server" MaxLength="4"></asp:TextBox>
    </p>
</div>

<asp:Button runat="server" ID="cmdSave" Text="Save" OnClick="cmdSave_Click" />   
<div id="addrDialog" title="Address Candidates" style="display:none">        
    <asp:ListBox ID="lstCandidates" runat="server" />
</div>

这是我背后的代码:

  protected void cmdSave_Click(object sender, System.EventArgs e)
    {
       .....//Call Web Service
        if (count > 0)
        {
            ClientScript.RegisterStartupScript(this.GetType(), "AddrDialog", "AddrDialog();", true);
        }
     }
  • 注意:我试图发布屏幕图片,但我没有足够的声誉,抱歉:)

我在这里错过了什么,请帮忙。谢谢

1 个答案:

答案 0 :(得分:1)

模态现在完美无缺。我打开对话框时添加了一行代码:

   function AddrDialog() {
  $(function () {
      $("#addrDialog").dialog("open");  
       $("#addrDialog").parent().appendTo($("form:first"));            
      return false;
  });