<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ProgressBar.aspx.cs" Inherits="Rating_ProgressBar" %>
<%@ Register TagPrefix="APNSoft" Namespace="APNSoft.WebControls" Assembly="APNSoftControls" %> 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Untitled Page</title>

    <script type="text/javascript">

        var InProgress=false;
        
        function Start(){
            if(InProgress == true) return;
            RequestServer();
            InProgress = true;
        }


        //Request the server to get the task status
        function RequestServer(){
            rt.CallTheServer('myRating', '', '');
        }


        //Refresh Progress Bar
        function RefreshProgressBar(ComponentID, SegmentID, SegmentValue, Parameter){
            
            //Get % complete for a task
            var Percentage = parseInt(Parameter);
            
            //Refresh Progress Bar & percentage
            rt.SetValue(ComponentID, Percentage);
            document.getElementById("percent").innerHTML = Percentage + '%';
            
            //Request the server each 50 milliseconds (if the task is not completed else)
            if(Percentage < 100){
                setTimeout(RequestServer, 50); //Request the Server again
            }else{
                InProgress = false;
                alert('The task is completed!');
            }
        };

    </script>

</head>
<body>
    <form id="form1" runat="server">
    <div>
    
    <APNSoft:APNSoftRating id="myRating" runat="server"
        SkinFolder = "~/Rating/Skins/ProgressBar/"
        ClientSideAfterCallBack = "RefreshProgressBar('', '', '', '$Parameter$');"
        ReadOnly = True
    /><span id="percent" style="position:relative;top:-4px;left:4px;">0%</span>

<br/><br/>
<a href="javascript:Start();">Start</a>



    </div>
    </form>
</body>
</html>