By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,334 Members | 2,776 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,334 IT Pros & Developers. It's quick & easy.

Ajax in C#

P: 179
I'm just wondering if anyone has used Ajax at all in C# without the use of ASP and if anyone could give me a pointer on getting started?

What I'm trying to do is quite simple, extend a small application which will send an Ajax request and retrieve a link from a website. The particular request is something along the lines of:

Expand|Select|Wrap|Line Numbers
  1. new Ajax.Request(url, {parameters:pars, onComplete:
  2.         function(r) {
  3.             var url = r.responseText;
  4.             Element.hide('loading');
  5.   'link_block');
  6.             if ('' == url) {
  7.                 $('link').innerHTML = 'Failure: cannot get download url...';
  8.             } else {
  9.                 $('link').innerHTML = '<a href="'+url+'">'+url+'</a>';
  10.             }
  11.         }
  12.     });
Once I've got this, I then actually need to grab the file at that location, however I'm thinking that .NET probably has some built in classes for remote grabbing of files.

What I'm really stumped on is how to easily include the Ajax request, in a purely winforms application, I can't seem to find any simple C# guides in Google. Anyone got any suggestions/starters?

Dec 22 '08 #1
Share this Question
Share on Google+
3 Replies

Expert 5K+
P: 7,872
Well ajax is the conceptual realization of a technology in web applications.

For windows applications your have more powerful objects. A similar one would be the HttpWebRequest. You don't need to execute javascript in a windows application.
Dec 22 '08 #2

Curtis Rutland
Expert 2.5K+
P: 3,256
Well, the reason that you can't find any tutorials is because AJAX has nothing to do with what you want. AJAX is just a nickname for a single javascript object and what you can do with it. So in a browser using JS you would be making an AJAX request, but in a desktop app, you are just making a web request.

You will want to look up HttpWebRequest. There's an example of how to use it near the bottom of the page.

Alternatively you can use the WebClient's DownloadFile method.
Dec 22 '08 #3

P: 270
Use backgroundworker control in your C# windows app to do your work/call functions asynchronously like AJAX
Dec 26 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.