Hello,
i will write a new application in ajax with a webservice. the website-project and the webservice-project should be in different solutions...i will not use updatapanels!
on my default.aspx i have an datagrid which is bind automaticle about a dataset. the grid support paging, but the request for the second page should be go to a webservice, which gives me only the data for the second page of the grid...
my question is: how can or should i bind the data on clientside to the datagrid ? should i write a own javascript function which fills the datagrid new or can i bind the xml data automaticly ? or if i become json back, how can i bind this automaticly ?
thx
yesso
Hi Yesso,
I think you've already had a general idea about how to implement this.
The datagrid control is finally rendered as a html table, and you need to
1) write the javascript function calling the web service
2) add a asynchronous call complete handler which fills the result in to the table
Here is an additional notification I'd like to mention when I noticed that there two different solutions.
By default, the XmlHttpRequest doesn't allow cross-domain post for security reason. That's to say, it may fail if you tries to access the web service via client directly.
For cross-domain we have to use proxy correct ?
Yes, you are right.
Calling WebServices using Javascript
If you are using Microsoft IE 5 or later, you can use the behavior/HTML-Component "WebService" to access a Web service. The "WebService" behavior communicates with Web services over HTTP using Simple Object Access Protocol (SOAP).
To use the "WebService" behavior, you must attach it to an element using the STYLE attribute, as follows:
<DIV ID="GiveItAName"
STYLE="behavior:url(webservice.htc)"></DIV>
A complete example taken from the Microsoft Web site is as follows:
<html>
<head>
<script language="JavaScript">
var iCallID;
function init()
{
service.useService
("http://myserver.com/services/myservice.asmx?WSDL",
"servicename");
}
function onmyresult()
{
if ((event.result.error)&&(iCallID==event.result.id))
{
var xfaultcode = event.result.errorDetail.code;
var xfaultstring = event.result.errorDetail.string;
var xfaultsoap = event.result.errorDetail.raw;
// Add code to output error information here
alert("Error ");
}
else
{
service.innerHTML= "The method returned the result: "
+ event.result.value;
}
}
</script>
</HEAD>
<body onload="init();">
<BR>
Enter a Value <input type='text' id='param1'>
<BR>
<button onclick='iCallID = service.servicename.callService
("ProcedureName", param1.value);'>Call A Web Method</button>
<div id="service"
style="behavior:url(webservice.htc)"
onresult="onmyresult();">
</div>
</body>
</html>
Let me know if you need more info.
You can also see this thread for more help:http://weblogs.asp.net/Varad/archive/2004/06/14/155671.aspx
No comments:
Post a Comment