I've done the following:
Made an AJAX call to a webservice that returns my slow generating image via
a byte[]. My problem is how to convert a byte[] in OnCompleteImageService
to an image to set the source!!!
Any ideas??
TIA
MattC
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs"
Inherits="TestingGround._Default" %>
<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Namespace="System.Web.UI" TagPrefix="asp" %>
<!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 runat="server">
<title>Untitled Page</title>
<script language="javascript" type="text/javascript">
function GetChartViaService(ID, element)
{
element.onload = "";
var SuccessCallBack = eval('OnComplete' + element.id);
TestingGround.AJAXServices.ChartService.ChartData(ID,
SuccessCallBack, FailedCallback);
}
function OnCompleteImageService(results)
{
//hmm byte[]to image???
document.getElementById('ImageService').src = results;
}
function FailedCallback(error)
{
var stackTrace = error.get_stackTrace();
var message = error.get_message();
var statusCode = error.get_statusCode();
var exceptionType = error.get_exceptionType();
var timedout = error.get_timedOut();
// Display the error.
var RsltElem =
document.getElementById("Results");
RsltElem.innerHTML =
"Stack Trace: " + stackTrace + "<br/>" +
"Service Error: " + message + "<br/>" +
"Status Code: " + statusCode + "<br/>" +
"Exception Type: " + exceptionType + "<br/>" +
"Timedout: " + timedout;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Scripts>
<asp:ScriptReference Path="~/AJAXServices/ChartService.asmx/js"
/>
</Scripts>
<Services>
<asp:ServiceReference Path="~/AJAXServices/ChartService.asmx"
InlineScript="true"/>
</Services>
</asp:ScriptManager>
<div>
<img alt="Test" id="ImageService" src="UIP.gif"
onload="javascript:GetChartViaService(3, this);" />
</div>
<div id="Results"></div>
</form>
</body>
</html>
Siva M said:
ASP.NET AJAX has support for both 'in progress' indication as well as
connecting to web services. For UpdateProgress see
http://ajax.asp.net/docs/tutorials/IntroductionUpdateProgress.aspx
For web service interaction from ASP.NET AJAX:
http://ajax.asp.net/docs/tutorials/ASPNETAJAXWebServicesTutorials.aspx
Hope this helps?
MattC said:
Hi,
I have a webservice that returns a byte[] for an image. I'd like to
disaplay an image while the webservice is being contacted and then once
the
byte[] is available show that and remove the please wait image.
I was thinking of trying to use the CallBack mechanism but wondered if
AJAX
would be better suited.
I'd really just appreciate some ideas on how this could be acheived.
I'll
need to do this many times on a page hence why I want to make each call
asychronous.
TIA
MattC