I want show a modal popup after my PDF file gets downloaded

I want show a modal popup after my PDF file gets downloaded

I want to show a modal pop up after my pdf gets downloaded successfully,everything is working but after response.end as you know no code gets executed I have tried with scriptmanager to open the modal but there was no success .Please help any help would be beneficial.

I want to show a modal pop up after my pdf gets downloaded successfully,everything is working but after response.end as you know no code gets executed I have tried with scriptmanager to open the modal but there was no success .Please help any help would be beneficial.

I think no code gets executed after response.end()

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HotelBAL;
using System.Data;
using iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.text.html.simpleparser;
using System.Web.Services;
using System.Web.Script.Services;

namespace HotelReservation.UserView { public partial class CancelBooking : System.Web.UI.Page { static int uid = 0;

            protected void Page_Load(object sender, EventArgs e)
                if (Session["UName"] == null)
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "stepconfirm3", "$('#loginbtn').hide();", true);
                    uid = Convert.ToInt32(Session["UId"]);  

            public  void BillDownloader(int uid, int bookingId, int totalPrice)
                    //PdfPTable pdfTable = 
                    DataTable dt = FileUtilityBal.CancelgeneratePDF(uid, bookingId);
                    GridView objGV = new GridView();
                    objGV.AutoGenerateColumns = false;
                    for (int i = 0; i < dt.Columns.Count; i++)
                        BoundField boundField = new BoundField();
                        boundField.DataField = dt.Columns[i].ColumnName.ToString();
                        boundField.HeaderText = dt.Columns[i].ColumnName.ToString();

                    objGV.DataSource = dt;
                    int columnsCount = objGV.Columns.Count;
                    PdfPTable pdfTable = new PdfPTable(columnsCount);

                    BaseFont btnColumnHeader = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
                    Font fntColumnHeader = new Font(btnColumnHeader, 10, 1);
                    for (int i = 0; i < dt.Columns.Count; i++)
                        PdfPCell cell = new PdfPCell();
                        cell.AddElement(new Chunk(dt.Columns[i].ColumnName.ToUpper(), fntColumnHeader));

                    for (int i = 0; i < dt.Rows.Count; i++)
                        for (int j = 0; j < dt.Columns.Count; j++)

                    Document pdfDocument = new Document(PageSize.A4, 10f, 10f, 10f, 10f);
                    PdfWriter.GetInstance(pdfDocument, HttpContext.Current.ApplicationInstance.Response.OutputStream);

                    var FontColour = new BaseColor(192, 192, 192);
                    var Calibri8 = FontFactory.GetFont("CALIBRI_BOLD", 35, FontColour);
                    Paragraph paragraph = new Paragraph("Cancellation Details", Calibri8);
                    paragraph.Alignment = Element.ALIGN_CENTER;
                paragraph.SpacingAfter = 10f;
                iTextSharp.text.Image jpg = iTextSharp.text.Image.GetInstance(HttpContext.Current.ApplicationInstance.Server.MapPath("../") + "/images/h-logo.jpg");
                jpg.ScaleToFit(150, 150);
                jpg.Alignment = Element.ALIGN_CENTER;

                var FontColour1 = new BaseColor(192, 192, 192);
                var Calibri9 = FontFactory.GetFont("CALIBRI_BOLD", 35, FontColour1);
                Paragraph p7 = new Paragraph("Invoice", Calibri9);
                p7.Alignment = Element.ALIGN_CENTER;
                p7.SpacingAfter = 30f;
                var FontColour2 = new BaseColor(255, 87, 51);
                var Calibri10 = FontFactory.GetFont("CALIBRI_BOLD", 15);
                var Calibri11 = FontFactory.GetFont("CALIBRI_BOLD", 15, FontColour2);
                Paragraph p2 = new Paragraph("       Refund Price (50% of Total)     Rs." + (totalPrice * 0.50) + "                     ", Calibri10);
                Paragraph p5 = new Paragraph("------------------------------------------------------------------------------------------------", Calibri10);
                Paragraph p6 = new Paragraph("                       TOTAL           Rs." + ((totalPrice * 0.50)) + "                     ", Calibri11);
                p2.Alignment = Element.ALIGN_CENTER;
                p2.SpacingBefore = 30f;
                p5.Alignment = Element.ALIGN_CENTER;
                p5.SpacingBefore = 30f;
                p6.Alignment = Element.ALIGN_CENTER;
                p6.SpacingBefore = 10f;
                Paragraph p8 = new Paragraph("CANCELLATION POLICY\n• Reservations made over 11-16 Sep 2018, 28-31 Dec 2018, 1-4 Jan 2019, 8-10 Aug 2019 and 28 Dec 2019 - 4 Jan 2020 require full pre-payment and are non-cancellable, non-amendable and non-refundable. The entire period of your stay, inclusive of nights before and after the dates listed above, will be charged to your credit card upon reservation.\n• Cancellation of and/or amendments to your reservation must be made 48 hours (i.e., by 4pm Singapore time) prior to your arrival date.\n• Cancellation or amendment made within 48 hours of arrival will incur a cancellation fee of one night's room charge (inclusive of any applicable prevailing government tax).\n• In the event of no-show, a fee of one night's room charge (inclusive of any applicable prevailing government tax) will be charged to your credit card provided at the time of reservation.");
                p8.Alignment = Element.ALIGN_LEFT;
                p8.SpacingBefore = 20f;
                //.RegisterStartupScript(this, GetType(), "YourUniqueScriptKey", " $('#MyModal').modal('show') ;", true);
                Response.ContentType = "application/pdf";
                Response.AppendHeader("content-disposition", "attachment;filename=hotel.pdf");
                Response.Cookies["cookie"].Value = "cookie value";
                Response.Cookies["cookie"].Expires = DateTime.Now.AddMinutes(1); 
            catch (Exception e)

        protected void btnSubmit_Click1(object sender, EventArgs e)
            CancelBookingBal bal = new CancelBookingBal();

            int BookingID = Convert.ToInt32(bid.Value);
            int uId = Convert.ToInt32(uid);
            int amount = 0;
            if (bal.updateUser(BookingID, uId))
                amount = UserBookingBal.getBookingAmt(BookingID);

                BillDownloader(uId, BookingID, amount);

The aspx page is as follows

    <%@ Page Title="" Language="C#" MasterPageFile="~/UserView/UserMasterPage.Master" AutoEventWireup="true" CodeBehind="CancelBooking.aspx.cs" Inherits="HotelReservation.UserView.CancelBooking" ClientIDMode="Static" EnableViewState="true" %>

&lt;asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server"&gt;
&lt;asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" runat="server"&gt;

        .hidden { display: none; }

    &lt;div class="container"&gt;
        &lt;div class="row"&gt;
            &lt;div class="form-control"&gt;
                &lt;br /&gt;
                &lt;br /&gt;
                &lt;h1&gt;Cancel Booking&lt;/h1&gt;
                &lt;br /&gt;
                &lt;br /&gt;

                &lt;div class="form-group"&gt;
                    &lt;label for="bno"&gt;Enter the booking number to cancel:&lt;/label&gt;
                    &lt;input type="text" class="form-control" id="bid" placeholder="Enter Number" name="bno" runat="server" /&gt;

                &lt;asp:Button ID="btnSubmit" runat="server" Text="Submit" CssClass="btn btn-primary" OnClick="btnSubmit_Click1"   /&gt;
               &lt;%-- &lt;button type="submit" id="cancelbtn" class="btn btn-primary" data-toggle="modal" runat="server"&gt;Submit&lt;/button&gt;--%&gt;

            &lt;div class="modal" id="MyModal"&gt;
                &lt;div class="modal-dialog"&gt;
                    &lt;div class="modal-content"&gt;

                        &lt;!-- Modal Header --&gt;
                        &lt;div class="modal-header"&gt;
                            &lt;h4 class="modal-title"&gt;Modal Heading&lt;/h4&gt;
                            &lt;button type="button" class="close" data-dismiss="modal"&gt;&amp;times;&lt;/button&gt;

                        &lt;!-- Modal body --&gt;
                        &lt;div class="modal-body"&gt;
                            You have successfully cancelled the Reservation !!!

                        &lt;!-- Modal footer --&gt;
                        &lt;div class="modal-footer"&gt;
                            &lt;button type="button" class="btn btn-danger" data-dismiss="modal"&gt;Close&lt;/button&gt;



&lt;asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" runat="server"&gt;

I have tried with scriptmanager to open the modal

 ScriptManager.RegisterStartupScript(this, GetType(), "YourUniqueScriptKey", " $('#MyModal').modal('show') ;", true);

I want to show modal to popup after the pdf gets downloaded.

Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Add asp.net Identity in empty project

LIKE | COMMENT | SHARE | SUBSCRIBE Today, in this tutorial you will see the process of adding an ASP.NET Identity to the ASP.NET Web Application developed in...

List all users from asp net core identity

LIKE | COMMENT | SHARE | SUBSCRIBE In this video, i will show you How to retrieve and display all the registered application users in asp.net core using the ...

Extend IdentityUser in ASP NET Core

LIKE | COMMENT | SHARE | SUBSCRIBE In this tutorials, I will show you how to extend IdentityUser in asp.net core.. Subscribe & Stay Connected! Thank You! ♥ #...