Hi,
I am struggling a bit to get a progress area from being displayed in IE. Basically I am calling a WebMethod from the JavaScript and the WebMethod is updating the ProgressArea. Here is an example of my code:
Javascript:
function IsLongRunningTaskCompleted(){
var lParams = GetPageMethodArguments();
var lLocation = window.location.href;
var lLocationToSubstringIndex = lLocation.search(".aspx?") + 5;
lLocation = lLocation.substr(0, lLocationToSubstringIndex);
$.ajax({
type : "POST",
url : lLocation + "/" + "ExecuteLongRunningTask",
data : "{" + lParams + "}",
contentType : "application/json; charset=utf-8",
dataType : "json",
success : function (pCurrentAction)
{
if (pCurrentAction.d == "Completed") CloseCurrentAspxPage();
window.setTimeout("IsLongRunningTaskCompleted()", 100);
},
fail : function (pCurrentAction)
{
CloseCurrentAspxPage();
}
});
}
}
Server side :
public class DoStuff
{
private static RadProgressContext FProgressArea;
private static double FCurrentPrecentage ;
protected void Page_Load(object sender, EventArgs e)
{
FProgressArea = RadProgressContext.Current;
FCurrentPrecentage = 0.0;
}
private delegate int ExecuteTimeConsumingProcessProcess();
[WebMethod]
public static string ExecuteLongRunningTask()
{
if (String.IsNullOrEmpty(FCurrentDuplicateStatus))
{
var lWriteInfoToDb = new WriteInfoToDB();
var lSavingStuff = new ExecuteTimeConsumingProcessProcess(lWriteInfoToDb.SaveALotOfData);
IAsyncResult lResult = lSavingStuff .BeginInvoke(null, null);
while (!lResult.IsCompleted)
{
FCurrentPrecentage = lSavingStuff.PercentageCompleted;
UpdateProgressBar(FProgressArea, FCurrentPrecentage );
Thread.Sleep(100);
}
lSavingStuff .EndInvoke(lResult);
FCurrentStatus = "Completed";
}
return FCurrentStatus ;
}
private static void UpdateProgressBar(RadProgressContext pProgressArea, double pPercentageCompleted)
{
const int cTotal = 100;
pProgressArea.Speed = "N/A";
pProgressArea.PrimaryTotal = 1;
pProgressArea.PrimaryValue = 1;
pProgressArea.PrimaryPercent = 100;
pProgressArea.SecondaryTotal = cTotal;
pProgressArea.SecondaryPercent = pPercentageCompleted;
pProgressArea.CurrentOperationText = "Step " + pPercentageCompleted;
Thread.Sleep(100);
}
}
In Firefox this is working perfectly well, but in IE I am not getting a progress area, and the page request times out. Have you got any idea what I am doing wrong by looking at the code? Or do you have any tips?
Thanks in advance.
I am struggling a bit to get a progress area from being displayed in IE. Basically I am calling a WebMethod from the JavaScript and the WebMethod is updating the ProgressArea. Here is an example of my code:
Javascript:
function IsLongRunningTaskCompleted(){
var lParams = GetPageMethodArguments();
var lLocation = window.location.href;
var lLocationToSubstringIndex = lLocation.search(".aspx?") + 5;
lLocation = lLocation.substr(0, lLocationToSubstringIndex);
$.ajax({
type : "POST",
url : lLocation + "/" + "ExecuteLongRunningTask",
data : "{" + lParams + "}",
contentType : "application/json; charset=utf-8",
dataType : "json",
success : function (pCurrentAction)
{
if (pCurrentAction.d == "Completed") CloseCurrentAspxPage();
window.setTimeout("IsLongRunningTaskCompleted()", 100);
},
fail : function (pCurrentAction)
{
CloseCurrentAspxPage();
}
});
}
}
Server side :
public class DoStuff
{
private static RadProgressContext FProgressArea;
private static double FCurrentPrecentage ;
protected void Page_Load(object sender, EventArgs e)
{
FProgressArea = RadProgressContext.Current;
FCurrentPrecentage = 0.0;
}
private delegate int ExecuteTimeConsumingProcessProcess();
[WebMethod]
public static string ExecuteLongRunningTask()
{
if (String.IsNullOrEmpty(FCurrentDuplicateStatus))
{
var lWriteInfoToDb = new WriteInfoToDB();
var lSavingStuff = new ExecuteTimeConsumingProcessProcess(lWriteInfoToDb.SaveALotOfData);
IAsyncResult lResult = lSavingStuff .BeginInvoke(null, null);
while (!lResult.IsCompleted)
{
FCurrentPrecentage = lSavingStuff.PercentageCompleted;
UpdateProgressBar(FProgressArea, FCurrentPrecentage );
Thread.Sleep(100);
}
lSavingStuff .EndInvoke(lResult);
FCurrentStatus = "Completed";
}
return FCurrentStatus ;
}
private static void UpdateProgressBar(RadProgressContext pProgressArea, double pPercentageCompleted)
{
const int cTotal = 100;
pProgressArea.Speed = "N/A";
pProgressArea.PrimaryTotal = 1;
pProgressArea.PrimaryValue = 1;
pProgressArea.PrimaryPercent = 100;
pProgressArea.SecondaryTotal = cTotal;
pProgressArea.SecondaryPercent = pPercentageCompleted;
pProgressArea.CurrentOperationText = "Step " + pPercentageCompleted;
Thread.Sleep(100);
}
}
In Firefox this is working perfectly well, but in IE I am not getting a progress area, and the page request times out. Have you got any idea what I am doing wrong by looking at the code? Or do you have any tips?
Thanks in advance.