Wednesday, March 21, 2012

Events

I would like to know if it is posible to obtain the data from theAtlas:datasource object via javascript.
When thedataAvailable event is raised, I'm able to capturre the event in javascript.
I see that it is sending two arguments with the event. I belive the first argument is the
sender and the second is an empty args value. Please correct me if this is wrong.

<!--
<div><spanid="RES">Some type of test data</span></div>


<atlas:DataSourcerunat="server"id="DataSource1"serviceUrl="~/DataService.asmx">
<dataAvailableHandler="traceDataAvailable1">
</dataAvailable>
</atlas:DataSource>

<scripttype="text/javascript">
function traceDataAvailable1()
{

var obj = arguments[0];
window.document.getElementById("RES").innerText = obj ;

}
</script>
-->

In your handler, "obj" will represent the datasource. So, to get to the data, you should do obj.get_data().
On a related note: you can rewrite traceDataAvailable1() to:
function traceDataAvailable(sender, eventArgs) {
...
}
Also, to display the data in the "res" span, you probably want toiterate over the contents of in the data object and concat it to the"innerHTML" property of the span.

No comments:

Post a Comment