Archie  Clayton

Archie Clayton

1548128217

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 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)
                {
                    Response.Redirect("../Views/Login.aspx");
                }
                else
                {
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "stepconfirm3", "$('#loginbtn').hide();", true);
                    uid = Convert.ToInt32(Session["UId"]);  
                }
            }

            public  void BillDownloader(int uid, int bookingId, int totalPrice)
            {
                try
                {
                    //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.Columns.Add(boundField);

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

                    //Header
                    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));
                        pdfTable.AddCell(cell);
                    }

                    //DataTable
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        for (int j = 0; j < dt.Columns.Count; j++)
                        {
                            pdfTable.AddCell(dt.Rows[i][j].ToString());
                        }
                    }

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

                    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;
                pdfDocument.Add(jpg);
                pdfDocument.Add(paragraph);

                pdfDocument.Add(pdfTable);
                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;
                pdfDocument.Add(p7);
                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;
                pdfDocument.Add(p2);
                p5.Alignment = Element.ALIGN_CENTER;
                p5.SpacingBefore = 30f;
                pdfDocument.Add(p5);
                p6.Alignment = Element.ALIGN_CENTER;
                p6.SpacingBefore = 10f;
                pdfDocument.Add(p6);
                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;
                pdfDocument.Add(p8);
                pdfDocument.Close();
                //.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); 
                Response.Write(pdfDocument);
                Response.Flush();
                Response.End();
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e.Message);
            }
        }

        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&gt;
&lt;asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" runat="server"&gt;

    &lt;style&gt;
        .hidden { display: none; }
    &lt;/style&gt;

    &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;/div&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&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;/div&gt;

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

                        &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;/div&gt;

                    &lt;/div&gt;
                &lt;/div&gt;
            &lt;/div&gt;

        &lt;/div&gt;
    &lt;/div&gt;

&lt;/asp:Content&gt;
&lt;asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" runat="server"&gt;
&lt;/asp:Content&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.


#c-sharp #asp.net

What is GEEK

Buddha Community

Joseph Norton

1548131456

You have to make it like this if your javescript for bootstrap is complete and include to the page:

<script type="text/javascript">

        function openModal() {
            $('#myModal').modal('show');
        }
</script>

.cs Code

 ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", openModal(), true);

if this not work, Check your bootstrap javascript.

This code:

 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);


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

Modal button ok on click

protected Modalbutton_onClick(object sender, EventArgs e)
{
   BillDownloader(uId, BookingID, amount);//Provide parameter on top 
}

Before this:

Modalbutton_onClick

You already check that the file is exists. The modal must throw a message first if file exist or not.

Charles Cooper

1548163000

Since you are using the cookies You can read it via jquery and invoke the modal.

  1. You need to include the cookie.download.js file - I am pasting it here
function getCookie(name) {
    var parts = document.cookie.split(name + "=");
    if (parts.length == 2) return parts.pop().split(";").shift();
}

function expireCookie(cName) {
    document.cookie =
        encodeURIComponent(cName) + "=deleted; expires=" + new Date(0).toUTCString();
}




var downloadTimer;
var attempts = 10;

// Prevents double-submits by waiting for a cookie from the server.
function blockResubmit() {
    var downloadToken = setFormToken();
    downloadTimer = window.setInterval(function () {
        var token = getCookie("cookie");
        if ((token == downloadToken) || (attempts == 0)) {

            $('#myModal').modal({
                backdrop: 'static',
                keyboard: false
            });
            $("#btnSubmit").removeAttr("disabled");
            unblockSubmit();
        }

        attempts--;
    }, 1000);
}

function unblockSubmit() {
    window.clearInterval(downloadTimer);
    expireCookie("cookie");
    attempts = 30;
}

  1. You need to include the cookie.download.js file - I am pasting it here
  $("#btnSubmit").click(function () {
        if ($("#form1").valid()) {
          
            blockResubmit();
                
        }
    });

  1. You need to include the cookie.download.js file - I am pasting it here
 System.Web.HttpCookie dwldCookie = new System.Web.HttpCookie("cookie", mdCookie.Value);
                                dwldCookie.Expires = DateTime.Now.AddYears(1);

                                Response.Cookies.Add(dwldCookie);

  1. You need to include the cookie.download.js file - I am pasting it here
 function setFormToken() {
        var downloadToken = makeid();
//Generate a random string using 
        document.getElementById("mdCookie").value = downloadToken;
        return downloadToken;
    }
function makeid() {
  var text = "";
  var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";

  for (var i = 0; i < 5; i++)
    text += possible.charAt(Math.floor(Math.random() * possible.length));

  return text;
}
<input type='hidden' id='mdCookie' name='mdCookie'/>

Cayla  Erdman

Cayla Erdman

1594369800

Introduction to Structured Query Language SQL pdf

SQL stands for Structured Query Language. SQL is a scripting language expected to store, control, and inquiry information put away in social databases. The main manifestation of SQL showed up in 1974, when a gathering in IBM built up the principal model of a social database. The primary business social database was discharged by Relational Software later turning out to be Oracle.

Models for SQL exist. In any case, the SQL that can be utilized on every last one of the major RDBMS today is in various flavors. This is because of two reasons:

1. The SQL order standard is genuinely intricate, and it isn’t handy to actualize the whole standard.

2. Every database seller needs an approach to separate its item from others.

Right now, contrasts are noted where fitting.

#programming books #beginning sql pdf #commands sql #download free sql full book pdf #introduction to sql pdf #introduction to sql ppt #introduction to sql #practical sql pdf #sql commands pdf with examples free download #sql commands #sql free bool download #sql guide #sql language #sql pdf #sql ppt #sql programming language #sql tutorial for beginners #sql tutorial pdf #sql #structured query language pdf #structured query language ppt #structured query language

Einar  Hintz

Einar Hintz

1602560783

jQuery Ajax CRUD in ASP.NET Core MVC with Modal Popup

In this article, we’ll discuss how to use jQuery Ajax for ASP.NET Core MVC CRUD Operations using Bootstrap Modal. With jQuery Ajax, we can make HTTP request to controller action methods without reloading the entire page, like a single page application.

To demonstrate CRUD operations – insert, update, delete and retrieve, the project will be dealing with details of a normal bank transaction. GitHub repository for this demo project : https://bit.ly/33KTJAu.

Sub-topics discussed :

  • Form design for insert and update operation.
  • Display forms in modal popup dialog.
  • Form post using jQuery Ajax.
  • Implement MVC CRUD operations with jQuery Ajax.
  • Loading spinner in .NET Core MVC.
  • Prevent direct access to MVC action method.

Create ASP.NET Core MVC Project

In Visual Studio 2019, Go to File > New > Project (Ctrl + Shift + N).

From new project window, Select Asp.Net Core Web Application_._

Image showing how to create ASP.NET Core Web API project in Visual Studio.

Once you provide the project name and location. Select Web Application(Model-View-Controller) and uncheck HTTPS Configuration. Above steps will create a brand new ASP.NET Core MVC project.

Showing project template selection for .NET Core MVC.

Setup a Database

Let’s create a database for this application using Entity Framework Core. For that we’ve to install corresponding NuGet Packages. Right click on project from solution explorer, select Manage NuGet Packages_,_ From browse tab, install following 3 packages.

Showing list of NuGet Packages for Entity Framework Core

Now let’s define DB model class file – /Models/TransactionModel.cs.

public class TransactionModel
{
    [Key]
    public int TransactionId { get; set; }

    [Column(TypeName ="nvarchar(12)")]
    [DisplayName("Account Number")]
    [Required(ErrorMessage ="This Field is required.")]
    [MaxLength(12,ErrorMessage ="Maximum 12 characters only")]
    public string AccountNumber { get; set; }

    [Column(TypeName ="nvarchar(100)")]
    [DisplayName("Beneficiary Name")]
    [Required(ErrorMessage = "This Field is required.")]
    public string BeneficiaryName { get; set; }

    [Column(TypeName ="nvarchar(100)")]
    [DisplayName("Bank Name")]
    [Required(ErrorMessage = "This Field is required.")]
    public string BankName { get; set; }

    [Column(TypeName ="nvarchar(11)")]
    [DisplayName("SWIFT Code")]
    [Required(ErrorMessage = "This Field is required.")]
    [MaxLength(11)]
    public string SWIFTCode { get; set; }

    [DisplayName("Amount")]
    [Required(ErrorMessage = "This Field is required.")]
    public int Amount { get; set; }

    [DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}")]
    public DateTime Date { get; set; }
}

C#Copy

Here we’ve defined model properties for the transaction with proper validation. Now let’s define  DbContextclass for EF Core.

#asp.net core article #asp.net core #add loading spinner in asp.net core #asp.net core crud without reloading #asp.net core jquery ajax form #asp.net core modal dialog #asp.net core mvc crud using jquery ajax #asp.net core mvc with jquery and ajax #asp.net core popup window #bootstrap modal popup in asp.net core mvc. bootstrap modal popup in asp.net core #delete and viewall in asp.net core #jquery ajax - insert #jquery ajax form post #modal popup dialog in asp.net core #no direct access action method #update #validation in modal popup

CodingNepal .

CodingNepal .

1617797839

Popup Share Modal UI Design using HTML CSS & JavaScript

#css share modal #modal dialog box #popup share modal #share modal #share modal in javascript

make duen

1622110483

How to Convert Multiple EML Files to PDF Adobe with Attachments

In this informative write-up, we try to assist all those users who need to know how to batch convert .eml to PDF documents. Here we will discuss a manual approach & automated solution to convert multiple EML files of any supported mail clients – Windows Live Mail, Windows Mail, eM Client, Outlook Express, DreamMail, etc into PDF Adobe documents. So keep reading this write-up to understand entire facts regarding to EML conversion to PDF.

EML is the single email file extension of multiple mail clients – Outlook Express, Thunderbird, Lotus Notes, DreamMail, eM Client, Windows Live Mail, Windows Mail, etc. Users can also get .eml files from the supported mail clients by drag & drop method. On the other side, PDF is the document file format of Adobe Reader that is available free of cost from freeware websites. PDF provides lots of simple & advanced functionalities so users are going with it. PDF is UNIVERSAL document file format and approved in all over the world for personal, professional & governmental work. It also provides protection facility to lock documents with user & owner password from unneeded access. Therefore, PDF demands are increasing day by day. Now the question arises that how to convert EML files to PDF Adobe documents. EML & PDF both are not a similar file extension so there is no direct migration solution available to do this task. But a manual trick can save few EML files to PDF. If you have proper time & few EML mails then you can follow the given steps of manual method -

How to Batch Convert .eml to PDF Manually

  • First of all, install Windows Live Mail in your system & also launch it on your desktop screen.
  • Create a new folder in Windows Live Mail with any name.
  • Select all EML files, drag them & drop in the newly created folder.
  • After that check all saved .eml files in Windows Live Mail.
  • Now select mail which you need to save emails to PDF.
  • Go to File Menu and Click on Print button.
  • Choose Microsoft Print to PDF option & Click on Print button.
  • Choose location where you want to save output files as PDF.

Note – Repeat this process to save multiple Windows Live Mail messages to PDF one by one. It is not suitable for large EML files migration to PDF. Sometimes, it fails due to technical issues. It cannot save emails to PDF with attachments properly. It is also a lengthy process so take lots of time of users.
How to Convert Multiple EML Files to PDF with Automated Solution

If you need urgent EML to PDF migration and also have large EML files database for conversion. Don’t want to go with the above explained manual solution then you can go with PCVARE EML to PDF Converter that has beneficial functions to provide safe, quick & complete EML conversion to PDF result. It is simple to use so anyone can handle it. The program can convert all EML files to PDF at once so you can get batch migration for .eml files to .pdf. It works smoothly and also convert batch EML files to PDF with attachments, formatting, hyperlinks, images, metadata, unread status, etc.

For your assistance, it provides free demo edition to check out its migration processing. So you can convert 25 EML files to PDF, after downloading & launching it on desktop screen. Therefore, you can clear your all doubts and solve how to convert multiple EML files to PDF problem. Therefore, you can try both of the explained solution at free of cost. So solve all problems freely.

#how to convert multiple eml files to pdf #how to batch convert .eml to pdf #eml #files #pdf

Vincent Lab

Vincent Lab

1605178557

Downloading Files using Node.js

In this video I will be showing you how to download files off the internet using Node.js

#node.js #downloading files #downloading git repos #download file #node.js tutorial #beginners