Click here to Skip to main content
15,914,905 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I want to show a Progress bar on a button click but it is not working as it has the postback trigger. If i remove the post back trigger progress bar is displaying but i have to put the postback trigger to show the reports(rdlc).

Thanks,
K.Vigneshwar
Posted
Comments
Please accept the answer if it helped you so that others can get it easily.
Otherwise it will be in the "Unanswered" list unnecessarily.
Thanks...

I faced the same problem before.
You need to add this script inside body.
There are two functions like "InitializeRequest" and "EndRequest", which will be called when update panel begin updating and end updating respectively.

C#
<script language="javascript" type="text/javascript">
                <!--
        var prm = Sys.WebForms.PageRequestManager.getInstance();
        function CancelAsyncPostBack() {
            if (prm.get_isInAsyncPostBack()) {
                prm.abortPostBack();
            }
        }
        prm.add_initializeRequest(InitializeRequest);
        prm.add_endRequest(EndRequest);
        var postBackElement;
        function InitializeRequest(sender, args) {
            if (prm.get_isInAsyncPostBack()) {
                args.set_cancel(true);
            }
            postBackElement = args.get_postBackElement();
            if (postBackElement.id == 'btnEdit') {
                // Loading the image which has display none property inside the  UpdateProgress control...(code is provided below)
                $("#loadingImage").css('display', 'block');
                
                // Reducing the opacity of the total table which contains the whole page controls...
                $('#totalTable').css('opacity', '0.20');
                $('#totalTable').css('filter', 'alpha(opacity=20)');
                $('#totalTable').css('filter', '"alpha(opacity=20)"');
            }
        }
        function EndRequest(sender, args) {
            if (postBackElement.id == 'btnEdit') {
                // Image is hided when updation is finished.
                $("#loadingImage").css('display', 'none');

                // Total table opacity also restored
                $('#totalTable').css('opacity', '1');
                $('#totalTable').css('filter', 'alpha(opacity=100)');
                $('#totalTable').css('filter', '"alpha(opacity=100)"');
            }
        }
                // -->
    </script>

C#
<asp:updateprogress id="UpdateProgress1" runat="server" associatedupdatepanelid="UpdatePanel" xmlns:asp="#unknown">
        <progresstemplate>
            <table>
                <tr>
                    <td style="width: 34%;">
                    </td>
                    <td id="loadingImage" style="display: none; removed 45%; opacity: 1; -moz-opacity: 1;<br mode=" hold=" />                        filter: alpha(opacity=100); filter: 'alpha(opacity=100)'; position: fixed; top: 40%;">
                        <img id="Img1" alt="No Image"  runat="server" src="~/img/progress_bar.gif" />
                    </td>
                </tr>
            </table>
        </progresstemplate>
    </asp:updateprogress>


This is just an example.
You can use the code and write what you want inside the "InitializeRequest" and "EndRequest" functions to accomplish your requirements.

Refer the link below for more information.

Programming UpdateProgress Controls in Client Script

Happy coding.....
 
Share this answer
 
v2
this is working for me
XML
<script type="text/javascript">
    var updateProgress = null;

    function postbackButtonClick() {
        updateProgress = $find("<%= UpdateProgress1.ClientID %>");
        window.setTimeout("updateProgress.set_visible(true)", updateProgress.get_displayAfter());
        return true;
    }
</script>



XML
<asp:UpdatePanel runat="server">
        <Triggers>
            <asp:PostBackTrigger ControlID="IBtnSave" />
        </Triggers>


this is button code for updatepanel

<asp:button id="IBtnSave" runat="server" text="Save" cssclass="art-button"
ClientIDMode="Static" onclick="IBtnSave_Click" OnClientClick="return postbackButtonClick();"/>
 
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