单击对话框中的aspx按钮时,Jquery对话框不会关闭

时间:2014-09-03 12:13:14

标签: javascript jquery asp.net jquery-dialog

我们在点击网格行时调用jquery对话框:

   protected void grdVendorContactDetails_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
e.Row.Attributes.Add("onclick", "displayContact('" + objlbl.Text + "')");
 }
  }

我的jquery对话框代码:

 function displayContact(ID) {

        var page ='VendorDetailsValidation.aspx?Id=' + ID  //get url of link
        var $dialog = $('<div></div>')
            .html('<iframe style="border: 0px; " src="' + page + '" width="100%" height="100%"></iframe>')

          .dialog({
                autoOpen: false,
                modal: true,
                height: 650,
                width: 800,
                title: "Validation Details",
                buttons: {
                    "Close": function () {
                        $(this).dialog("close");
                    }
                }


            });
                     $dialog.dialog('open');

    }

我的Venodordeatails aspx页面:

       <table  style="font-weight:normal; margin-top:-20px;" width="100%" border="0" cellpadding="2" cellspacing="2">
<tr>
    <td class="DivH1"  style="color:Red;width:95%;" colspan="4"> Validate : 
   <asp:Label ID="lblValidate" runat="server" Text="Label" Style="color:Black;"></asp:Label></td> 
</tr>

<tr>
    <td class="LabelBoldLeft"> Vendor </td>
    <%--<td><asp:Label ID="lblReqID" runat="server" Text="" CssClass = "fieldText" ReadOnly = "false"  style="color:Black;"></asp:Label></td> --%>
    <td class="LabelBoldLeft"> Type  </td>
    <%--<td><asp:Label ID="lblReqType" runat="server" Text="" CssClass = "fieldText reqltrType" ReadOnly = "false" style="color:Black;"></asp:Label></td>  --%>
    <td class="LabelBoldLeft"> Contact Name </td> 
   <%-- <td><asp:Label ID="lblReqStatus" runat="server" Text="New" CssClass = "fieldText" ReadOnly = "false" style="color:Black;"></asp:Label></td>             --%>
</tr>
<tr>
    <td><asp:Label ID="lblVendor" runat="server" Text="" CssClass = "Label" ReadOnly = "false"  style="color:Black;"></asp:Label></td>
    <td><asp:DropDownList ID="ddlType" style="float:left;width:65%;" runat="server" CssClass="DropDownCtrl"  DataTextField="IDDESC" DataValueField="ID"></asp:DropDownList>   
    </td>
  <%--  <td class="frmlblBold"> Travel To</td>--%>
    <%--<td class="fieldToggle mandatory"><asp:DropDownList ID="ddlTravelTo" style="float:left;width:65%;" runat="server" CssClass="reqDet reqDetdrop toggleDdl ddlTrvTo ddlTrv"  DataTextField="CDDesc" DataValueField="CODE"   AutoPostBack="True" ></asp:DropDownList>

    </td>--%>
    <td><asp:TextBox ID="txtContactName" runat="server" CssClass="TextBoxCtrl"></asp:TextBox></td>

    <%--<td class="frmlblBold"></td>--%>

</tr>
 <tr>
    <td class="LabelBoldLeft"> Product/App </td>
    <%--<td><asp:Label ID="lblReqID" runat="server" Text="" CssClass = "fieldText" ReadOnly = "false"  style="color:Black;"></asp:Label></td> --%>
    <td class="LabelBoldLeft"> Responsibility  </td>
    <%--<td><asp:Label ID="lblReqType" runat="server" Text="" CssClass = "fieldText reqltrType" ReadOnly = "false" style="color:Black;"></asp:Label></td>  --%>
    <td class="LabelBoldLeft"> Platform </td> 
   <%-- <td><asp:Label ID="lblReqStatus" runat="server" Text="New" CssClass = "fieldText" ReadOnly = "false" style="color:Black;"></asp:Label></td>             --%>
</tr>
<tr>
    <td><asp:TextBox ID="txtProduct" runat="server" CssClass="TextBoxCtrl"></asp:TextBox></td>

    <td><asp:DropDownList ID="ddlResponsibility" style="float:left;width:65%;" runat="server" CssClass="DropDownCtrl"  DataTextField="IDDesc" DataValueField="ID"></asp:DropDownList>   
    </td>
    <td><asp:DropDownList ID="ddlPlatform" style="float:left;width:65%;" runat="server" CssClass="DropDownCtrl"   DataValueField="platform"></asp:DropDownList>   
    </td>

</tr>


    <tr>
    <td class="LabelBoldLeft"> Line of Business </td>
   <td class="LabelBoldLeft"> Status </td>


</tr>
<tr>


    <td>   
        <asp:TextBox ID="txtLob" runat="server" CssClass="TextBoxCtrl"></asp:TextBox>
    </td>
  <td> <asp:RadioButtonList  ID="rblStatus" runat="server" RepeatDirection = "Horizontal">
    <asp:ListItem Text="Active" Value="1"></asp:ListItem>
    <asp:ListItem Text="Disabled" Value="0"></asp:ListItem>
    </asp:RadioButtonList></td>
</tr>
     <tr>
    <td class="DivH1" colspan="4" style="color:Red;"> Contact Details :
    <asp:Label ID="lblCntName" runat="server" Text="" CssClass = "Label" ReadOnly = "false"  style="color:Black;"></asp:Label></td>
</tr>
 <tr>
    <td class="LabelBoldLeft"> Office#  </td>
     <td class="LabelBoldLeft"> Mobile#  </td> 
    <td class="LabelBoldLeft"> Pager# </td> 

</tr>
<tr>

    <td><asp:TextBox ID="txtOffice" runat="server" CssClass="TextBoxCtrl"></asp:TextBox></td>
    <td><asp:TextBox ID="txtMobile" runat="server" CssClass="TextBoxCtrl"></asp:TextBox></td>
    <td><asp:TextBox ID="txtPager" runat="server" CssClass="TextBoxCtrl"></asp:TextBox></td>

</tr>
 <tr>
    <td class="LabelBoldLeft"> General Hotline# </td>

    <td class="LabelBoldLeft"> Email ID </td>

    <td class="LabelBoldLeft"> Pin </td> 

</tr>
<tr>

    <td><asp:TextBox ID="txtHotline" runat="server" CssClass="TextBoxCtrl"></asp:TextBox></td>
    <td><asp:TextBox ID="txtEmail" runat="server" CssClass="TextBoxCtrl"></asp:TextBox></td>
    <td><asp:TextBox ID="txtPin" runat="server" CssClass="TextBoxCtrl"></asp:TextBox></td>

</tr>


    <tr>
    <td class="DivH1" colspan="4" style="color:Red;"> Validation Details </td>

</tr>
    <tr>
        <td class="LabelBoldLeft"> Last Validated By</td>

    <td class="LabelBoldLeft"> Last Validated On  </td>
    <td class="LabelBoldLeft"> Last Modified By</td>

    <td class="LabelBoldLeft"> Last Modified On  </td>

    </tr>
<tr>
       <td><asp:Label ID="lblValBy" runat="server" Text="Label" CssClass = "Label"></asp:Label></td> 
    <td><asp:Label ID="lblValon" runat="server" Text="Label" CssClass = "Label"></asp:Label></td> 
    <td><asp:Label ID="lblModBy" runat="server" Text="" CssClass = "Label"></asp:Label></td>
    <td><asp:Label ID="lblModOn" runat="server" Text="Label" CssClass = "Label"></asp:Label></td>  

</tr>
<tr>
    <td class="LabelBoldLeft"> Notes </td>
</tr>
<tr>
   <td colspan="2"> 
   <asp:TextBox ID="txtNotes" runat="server" TextMode="Multiline" Columns="40" Rows="5"></asp:TextBox>
   </td>
    <td><%--<asp:LinkButton ID="lnkCancel" runat="server" 
            onclick="lnkCancel_Click" CssClass="LabelHyperLink">Cancel</asp:LinkButton>--%>
    <asp:Button ID="btnSave" runat="server" Text="Save" onclick="btnSave_Click"  class="buttonSecondary"  />&nbsp;&nbsp;
    <asp:Button ID="btnValidate" runat="server" Text="Validate" 
            onclick="btnValidate_Click" CssClass="btnClass" /></td>


</tr>
 </table>

单击“保存”按钮我必须关闭我的jquery对话框:我使用了以下代码并且无法正常工作:

 protected void btnSave_Click(object sender, EventArgs e)
{
   string id = Request.QueryString["Id"].ToString();
    obj.Type = ddlType.SelectedValue;
    obj.ContactName = txtContactName.Text;
    obj.Product = txtProduct.Text;
    obj.Responsibility = ddlResponsibility.SelectedValue;
    obj.Platform = ddlPlatform.SelectedValue;
    obj.LOB = txtLob.Text;
    obj.Office = txtOffice.Text;
    obj.Mobile = txtMobile.Text;
    obj.Pager = txtPager.Text;
    obj.Hotline = txtHotline.Text;
    obj.Emailid = txtEmail.Text;
    obj.Pin = txtPin.Text;
    obj.Status = rblStatus.SelectedValue;
   obj.Notes = txtNotes.Text;


    obj.SaveVendorDetails(id);
 ScriptManager.RegisterStartupScript(this,GetType(), "tmp", "<script type='text/javascript'>Confirm();</script>",false);

 }


  function Confirm() {

                    $(this).dialog('close');
                 }

当我尝试关闭时,我收到错误.Plz让我知道如何关闭对话框。 我得到$(this).val()为undefined或null

1 个答案:

答案 0 :(得分:0)

您正在执行代码隐藏点击。阅读按钮OnClientClick Property以执行您的JavaScript客户端而无需回发。