Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>there are a couple of things that you are probably doing wrong.</p> <p>First of all the initialization of the dialog, qhere did you puted it? in </p> <pre><code>$(document).ready( function() { ... } ); </code></pre> <p>if not, you should. Taking that you do redirect the user and in that redirect you redirect to the previous page (the one that have the dialog) so (document).ready is fired up again and initializes the dialog.</p> <p>But, using ASP.NET you should not do this like you are doing, think about a simple form, to you and the user.</p> <p>using .load in jQuery you can load a diferent page, so let's imagine that you have a button in the dialog called "I agree" that gives the user the requested file:</p> <pre><code>$(document).ready( function() { $("#terms-dialog").dialog({ modal: true, autoOpen: false, autoResize: false, height: 420, width: 500, overlay: { opacity: 0.5, background: "black" }, buttons: { I do not agree: function() { $(this).dialog('close'); } I agree: function() { GetFileIfCookieExist("myfile.xls"); $(this).dialog('close'); } } }); }); function GetFileIfCookieExist(file) { // create cookie here $.load("getFile.aspx", { "f": file }, function() { // you can show a "loading" image }); } </code></pre> <p>in your getFile.aspx, delete all HTML code except 1st line and in the code-behind Page_Load event process the request and write the document back using the Response.Write method like:</p> <pre><code>Response.Clear(); Response.AddHeader("content-disposition", "attachment;filename=" + Request["f"]); Response.Charset = ""; Response.ContentType = "application/vnd.xls"; System.IO.StringWriter stringWrite = new System.IO.StringWriter(); stringWrite = AppendMyFile(); Response.Write(stringWrite.ToString()); Response.End(); </code></pre> <p>remember to create a cookie in the request and check that cookie in the aspx page, if it does not exist that's because a user forced it's download, and then delete the cookie before sending the file back to the user.</p> <p>the cookie is only a strategy to assure credebility, but it's not flawless cause you need the user to have cookies enable (like Hotmail does in order you to read email in it's website), you can use Session object or other method that you can think about.</p> <p>This is only so you can have a better idea of what you can accomplish.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload