Getting a DataTable from server and working with it in Javascript (VB.NET)

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?”


Welcome!

As some of you may have already seen my other blog codingreblogger.wordpress.com , I’m currently developing a rather experimental web site based on reblogger engine that takes advantage of the new Microsoft framework Atlas.

Since Atlas is currently in a preview stage, I’ve noticed that there is a quite a shortage of information, examples and tutorials on Atlas. In process of developing reblogger.com I’ve gone through quite a journey to understand Atlas, it’s usage and taking a full advantage of it.

The purpose of this blog is to make it easier to people that want to use Atlas in their web development taks. I will post as much of examples as time allows, which will mainly describe the scenarios used on reblogger.com. In case you have questions, suggestions or catch me doing something “the stupid way”, I encourage you all to send feedback. I will greatly appreciate it.

Thanks,
Ivan


This blog is being delivered to you by
reBlogger.com
“Do you know what your employees are blogging about?”


Follow

Get every new post delivered to your Inbox.