Would love to be able to use Words from button inside a UpdateProgress + UpdatePanel AJAX components

Just thought I’d toss out an idea that I’d love to see:

I’d like to have a button (that calls Aspose.Words) from within an AJAX UpdatePanel so that I can use the UpdateProgress component. (Sometimes our merging process takes 10-20 seconds, and it would be great to give the user a visual clue that processing is taking place.)

I realize that the doc.Save method (with OpenInWord) sets the HTTP headers, which makes the Save method essentially incompatible with the AJAX UpdatePanel, but perhaps it would be possible to indicate to the Document that it’s contained in the UpdatePanel and to return a multi-part response?

Yes, I’ve seen the alternative of writing the Document to disk and giving the user a link to download it, but that isn’t an option in my specific instance.

Thanks for thinking about this.

Hi

Thanks for your request. You can try to show message “Generating document…” using JavaScript. See the following example.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

    <title>Generate Document</title>

    <script type="text/javascript" language="javascript">
        function showMessage()
        {
          message.innerText="Generating document...";
        }
    </script>

    <script runat="server" language="C#">

        protected void Button1_Click(object sender, EventArgs e)
        {
            Aspose.Words.Document doc = new Aspose.Words.Document();
            Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
            for (int i = 0; i < 100000; i++)
            {
                builder.Writeln("test");
            }
                doc.Save("test.doc", Aspose.Words.SaveFormat.Doc, Aspose.Words.SaveType.OpenInWord, Response);
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true" />
        <div>
            <asp:Button ID="Button1" runat="server" Text="Generate document" OnClientClick="showMessage();"  OnClick="Button1_Click"  />
            <span id="message"></span>
        </div>
    </form>
</body>
</html>

I hope that it will help you.

That’s a good solution with the exception of the fact that the “Generating document…” message will not go away when the document arrives in the browser. It’s very close to what I’m trying to accomplish!

Thank you!

Hi

Try to use the following code snippet.

<script type="text/javascript" language="javascript">

    function showMessage()
    {
        message.style.visibility = "visible";
    }

    function hideMessage()
    {
        message.style.visibility = "hidden";
    }
   
</script>

 
<body onfocusout="hideMessage()">

I hope that it will help you.

Once again, Vitaly, you’ve gone above and beyond. Thanks very much for this. I forgot about the onfocusout event and that did the trick.