For any Asp.NET developer one of the most common scenarios is retrieving data in form of a DataTable from server (unless, you are dead serious about using data reader
). So how to do it with Atlas and avoid postback… quite simple actually.
First what you need to do is create a web service file which you will use to retrieve data. To do that, you would go to Visual Studio (assuming you have created a web site already), right-click on your web site in Solution Explorer, then click “Add new item”. Choose “Web Service”, name it GetData.asmx and make sure to uncheck the “Place code in separate file” checkbox.
Make that file look like this :
OPEN CODE IN NEW WINDOW
Now when we have our web service set up, we’ll go to the .aspx page and retrieve that data with atlas. I’m assuming here you know the basics of Atlas, so I won’t go into details. Just remember to put a script manager tag just
under your body tag… should look something like this (make sure you set the service reference to the webservice you’ve just created) :
OPEN CODE IN NEW WINDOW
…Now, we are all set to go into javascript and write the code to get the DataTable. You will basically have two functions, one that will call the function we’ve made in our web service, and other that will receive the datatable as a parameter from our web service functions. It will look something like this :
OPEN CODE IN NEW WINDOW
And that’s all there is to it. No postbacks
You may want to read this great “Quick Reference for the Atlas DataTable” by Garbin (my advice is to read pretty much anything where you see Garbin underneath, this guy rocks!).Ohh yeah, if I messed up something while writing this post or you have trouble to get it working, feel free to contact me.
This blog is being delivered to you by
reBlogger.com
“Do you know what your employees are blogging about?”





