Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have added a popup

This is my popup....

<div class="modal fade" id="MyDispach"  role="dialog" style="width:300px; left:500px; top:80px">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-body" style="text-align: left">
                <p><span>Log ID:</span> <asp:TextBox runat="server" ID="txtNumber" ValidationGroup="FormVG"></asp:TextBox><asp:RequiredFieldValidator ID="RequiredFieldValidator_txtLogNumber" runat="server" ErrorMessage="*" ForeColor="Red" ValidationGroup="FormVG" ControlToValidate="txtNumber"></asp:RequiredFieldValidator></p>
            </div>
            <div class="modal-footer" style="padding: 8px; text-align: left;">

                <p style="padding-left: 20px">
                    <asp:Button runat="server" ID="Btngeneratedispatchrelease" UseSubmitBehavior="true" ValidationGroup="FormVG" class="btn btn-primary" Text="Generate PDF"  OnClick="Btngeneratedispatchrelease_Click" />


                </p>

            </div>
            <div>
                <p>
                    <asp:Label ID="lblmsg" Text="" runat="server" ForeColor="Green"></asp:Label>
                </p>
            </div>
        </div>

    </div>
</div>


What I have tried:

protected void Btngeneratedispatchrelease_Click(object sender, EventArgs e)
      {
          //ScriptManager.RegisterStartupScript(this, this.GetType(), "HidePopup", "$('#MyDispach').modal('show')", true);
          ClientScriptManager.(this, this.GetType(), "onclick", "window.close()", true);
          //textdd_Click(null, null);
          //ScriptManager.RegisterStartupScript(this, this.GetType(), "CloseModalPopup", "CloseModalPopup();", true);
          GeneratePDF();// This is PDF generate method..
          ScriptManager.RegisterStartupScript(this, this.GetType(), "HidePopup", "$('#MyDispach').modal('show')", true);


      }


function CloseModalPopup() {
           debugger;
           $('#MyDispach').modal("hide");
       }


NOTE:- If a pdf generate method comment or remove .It's working fine. But I need with PDF Generate method.
Please help..
Thanks
Posted
Updated 5-Apr-23 21:44pm
Comments
mtoha 6-Apr-23 3:38am    
This script shoould replaced : ScriptManager.RegisterStartupScript(this, this.GetType(), "HidePopup", "$('#MyDispach').modal('show')", true);
to :
ScriptManager.RegisterStartupScript(this, this.GetType(), "HidePopup"+Guid.NewGuid().ToString(), "$('#MyDispach').modal('hide')", true);

Use developer mode, and run at console,
$('#MyDispach').modal("hide");
is the modal closed?

if your key isn't changed this script will only execute once

1 solution

This script shoould replaced :
ScriptManager.RegisterStartupScript(this, this.GetType(), "HidePopup", "$('#MyDispach').modal('show')", true);

to :
ScriptManager.RegisterStartupScript(this, this.GetType(), "HidePopup"+Guid.NewGuid().ToString(), "$('#MyDispach').modal('hide')", true);


Use developer mode, and run at console,
$('#MyDispach').modal("hide");

is the modal closed?

if your key isn't changed this script will only execute once

Other Wise You can Use

ClientScript.RegisterStartupScript
        (GetType(),Guid.NewGuid().ToString(), "CloseModalPopup();",true);
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900