AJAX.Net
1. What is AJAX?
Ajax stands for Asynchronous Javascript & XML. It is a web technology through which a postback from a client (browser) to the server goes partially, which means that instead of a complete postback, a partial postback is triggered by the Javascript XmlHttpRequest object. In such a scenario, web-application users won't be able to view the complete postback progress bar shown by the browser. In an AJAX environment, it is Javascript that starts the communication with the web server. Ajax technology in a website may be implemented by using plain Javascript and XML. Code in such a scenario may tend to look little complex, for which the AJAX Framework in .NET can be embedded in ASP.NET web applications. In addition to XML & Javascript, AJAX is also based on DOM - the Document Object Model technology of browsers through which objects of the browser can be accessed through the memory heap using their address. JSON - Javascript Object Notation is also one of the formats used in AJAX, besides XML. So basically, in an AJAX-based web application, the complete page does not need to reload, and only the objects in context are reloaded. Ajax technology avoids the browser flickering, improves performance, reliable, more fast and compatible, etc.
2. What is DOM?
DOM stands for Document Object Model, it is a application programming interface(API) for valid HTML and XML document. It defines what attributes are associated with what objects, using DOM make XMLHTTPRequest to web server. The web browser recognises it as a tree structure of elements.
3. Is it any web servers independently?
Yes, AJAX is a technology independent of web server the web application is hosted on. Ajax is a client (browser) based technology.
4. Which browsers support the XmlHttpRequest object?
Internet Explorer 5.0+, Safari 1.2, Mozilla 1.0/Firefox, Opera 8.0 +, Netscape 7
5. How to create an XmlHttpRequest object for different browsers?
For Internet Explorer, an ActiveXObject is used for declaring an XmlHttpRequest object in Javascript. //Code as below for IE: xmlHttpObject = new ActiveXObject("Msxml2.XMLHTTP"); //For Other browsers, code as below: xmlHttpObject = new XMLHttpRequest(); Note that XmlHttpObject used above is simply a variable for the respective browsers.
6. What are the properties of XmlHttpRequest object? What are the different types of readyStates in Ajax?
i) onreadyStateChange - This function is used to process the reply from the web server. ii) readyState - This property holds the response status of the web server. There are 5 states: 1 - request not yet initialized 2 - request now set 3 - request sent 4 - request processing 5 - request completes
7. What is ATLAS?
Before Microsoft AJAX, it was ATLAS.
8. What is the ASP.NET Ajax Framework? What versions have been released so far?
ASP.NET AJAX is a free framework to implement Ajax in asp.net web applications, for quickly creating efficient and interactive Web applications that work across all popular browsers. The Ajax Framework is powered with 1 - Reusable Ajax Controls - AJAX Custom Controls, Ajax Tool Kit (Codeplex), etc 2 - Support for all modern browsers 3 - Access remote services and data from the browser without tons of complicated script. Versions of Ajax release ASP.NET Ajax Framework 1.0 (earlier release to this was called the Atlas) ASP.NET Ajax Framework 1.0 was available as a separate download for ASP.NET 2.0
9. What are Ajax Extensions?
The ASP.NET Ajax Extensions are set of Ajax-based controls that work in ASP.NET 2 (or above) based applications. Of course, they also need the Ajax runtime which is actually the Ajax Framework 1.0. ASP.NET Ajax Extensions 1.0 have to be downloaded to run with ASP.NET 2.0 The new ASP.NET 3.5 Framework comes with the Ajax Library 3.5 (containing the Ajax Extensions 3.5). So in order to use the latest Ajax, simply download .NET 3.5 Framework.
10. What is the ASP.NET Control Toolkit?
Besides the Ajax Framework (which is the Ajax engine) and Ajax Extensions (which contain the default Ajax controls), there is a toolkit called the Ajax Control Toolkit available for use & download (for free). This is a collection of rich featured, highly interactive controls, created as a joint venture between Microsoft & the Developer Community(CodePlex).
11. How to create an AJAX website using Visual Studio?
Using Visual Studio Web Developer Express 2005 & versions above it, Ajax based applications may easily be created. Note that the Ajax Framework & Ajax Extensions should be installed (In case of VS 2005). If using Visual Studio 2008 Web Developer Express or above, Ajax comes along with it (so no need of a separate installation). Steps: Start Visual Studio, Click on File -> New Website -> Under Visual Studio Installed templates -> Select ASP.NET Ajax-Enabled Site. Enter a location & select OK.
12. How to handle multiple or concurrent requests in Ajax?
For concurrent requests, declare separate XmlHttpRequest objects for each request. For example, for request to get data from an SQL table1, use something like this... xmlHttpObject1.Onreadystatechange = functionfromTable1(); and to get data from another table (say table2) at the same time, use xmlHttpObject2.Onreadystatechange = functionfromTable2(); Ofcourse, the XmlHttpObject needs to be opened & parameters passed too, like as shown below... xmlHTTPObject1.open("GET","http://"localhost// " + "Website1/Default1.aspx" true); Note that the last parameter "true" used above means that processing shall carry on without waiting for any response from the web server. If it is false, the function shall wait for a response.
13. Can we override the EnablePartialRendering property of the ScriptManager class?
Yes. But this has to be done before the init event of the page (or during runtime after the page has already loaded). Otherwise an InvalidOperationException will be thrown.
14. How to use multiple ScriptManager controls in a web page?
No. It is not possible to use multiple ScriptManager control in a web page. In fact, any such requirement never comes in because a single ScriptManager control is enough to handle the objects of a web page. We can use multiple update panels.
15. Whats the difference between RegisterClientScriptBlock, RegisterClientScriptInclude and RegisterClientScriptResource?
For all three, a script element is rendered after the opening form tag. Following are the differences: 1 - RegisterClientScriptBlock - The script is specified as a string parameter. 2 - RegisterClientScriptInclude - The script content is specified by setting the src attribute to a URL that points to a script file. 3 - RegisterClientScriptResource - The script content is specified with a resource name in an assembly. The src attribute is automatically populated with a URL by a call to an HTTP handler that retrieves the named script from the assembly.
16. What are type/key pairs in client script registration? Can there be 2 scripts with the same type/key pair name?
When a script is registered by the ScriptManager class, a type/key pair is created to uniquely identify the script. For identification purposes, the type/key pair name is always unique for dentifying a script. Hence, there may be no duplication in type/key pair names.
17. What is an UpdatePanel Control?
An UpdatePanel control is a holder for server side controls that need to be partial postbacked in an ajax cycle. All controls residing inside the UpdatePanel will be partial postbacked. Below is a small example of using an UpdatePanel. As you see here after running the snippet above, there wont be a full postback exhibited by the web page. Upon clicking the button, the postback shall be partial. This means that contents outside the UpdatePanel wont be posted back to the web server. Only the contents within the UpdatePanel are refreshed.
18. How to control how long an Ajax request may last?
Use the ScriptManager's AsyncPostBackTimeout Property.
19. What are limitations of Ajax?
An Ajax Web Application tends to confused end users if the network bandwidth is slow, because there is no full postback running. However, this confusion may be eliminated by using an UpdateProgress control in tandem. Which update information to the user.
20. How to make sure that contents of an UpdatePanel update only when a partial postback takes place (and not on a full postback)?
Make use of ScriptManager.IsInAsyncPostBack property (returns a boolean value)
21. Which request is better with AJAX, Get or Post?
AJAX requests should use an HTTP GET request while retrieving data where the data does not change for a given URL requested. An HTTP POST should be used when state is updated on the server. This is in line with HTTP idem potency recommendations and is highly recommended for a consistent web application architecture.
22. Is the server or the client in control in AJAX?
It depends. With AJAX the answer is more in between. Control can be more centralized in a server-side component or as a mix of client-side and server-side controllers. Centralized server-side controller - When having a more centralized controller the key is to make sure the data in client-side page is in sync with that of the server. Some applications may keep all the state on the server and push all updates to client DOM via a simple JavaScript controller. Client and server-side controllers - This architecture would use JavaScript to do all presentation related control, event processing, page manipulation, and rendering of model data on the client. The server-side would be responsible for things such as business logic and pushing updated model data to the client. In this case the server would not have intimate knowledge of the presentation short of the initial page that would be sent to the client page request. There are some use cases where an entire AJAX application can be written in a single page. Keep in mind if you choose this type of architecture that navigation and bookmarking should be considered.
23. Does Java have support for server-side push?
Current AJAX applications use polling to communicate changes data between the server and client. Some applications, such as chat applications, stock tickers, or score boards require more immediate notifications of updates to the client. Comet is an event based low latency server side push for AJAX applications. Comet communication keeps one of the two connections available to the browser open to continuously communicate events from the server to the client.
24. Who is Using Ajax ?
Google is making a huge investment in developing the Ajax approach. All of the major products Google has introduced over the last year in Orkut, Gmail, the latest beta version of Google Groups, Google Suggest, and Google Maps are Ajax applications. (For more on the technical nuts and bolts of these Ajax implementations, check out these excellent analyses of Gmail, Google Suggest, and Google Maps.) Others are following suit: many of the features that people love in Flickr depend on Ajax, and Amazon.com search engine applies similar techniques. These projects demonstrate that Ajax is not only technically sound, but also practical for real-world applications. Ajax applications can be any size, from the very simple, single-function Google Suggest to the very complex and sophisticated Google Maps. Ajax is an important development for Web applications, and its importance is only going to grow. And because there are so many developers out there who already know how to use these technologies, we expect to see many more organizations nowadays web development. Moving Forward The biggest challenges in creating Ajax applications are not technical. The core Ajax technologies are mature, stable, and well understood. Instead, the challenges are for the designers of these applications: to forget what we think we know about the limitations of the Web, and begin to imagine a wider, richer range of possibilities
25. What do I need to know to create my own AJAX functionality?
Learn HTML & Dynamic HTML (DHTML), the technology that is the foundation for AJAX. DHTML enables browser-base real time interaction between a user and a web page. DHTML is the combination of JavaScript, the Document Object Model (DOM) and Cascading Style Sheets (CSS). * JavaScript - JavaScript is a loosely typed object based scripting language supported by all major browsers and essential for AJAX interactions. JavaScript in a page is called when an event in a page occurs such as a page load, a mouse click, or a key press in a form element. * DOM - An API for accessing and manipulating structured documents. In most cases DOM represent the structure of XML and HTML documents. * CSS - Allows you to define the presentation of a page such as fonts, colors, sizes, and positioning. CSS allow for a clear separation of the presentation from the content and may be changed programmatically by JavaScript. Understanding the basic request/response nature of HTTP is also important. Many subtle bugs can result if you ignore the differences between the GET and OIst methods when configuring an XMLHttpRequest and HTTP response codes when processing callbacks. JavaScript is the client-side glue, in a sense. JavaScript is used to create the XMLHttpRequest Object and trigger the asynchronous call. JavaScript is used to parse the returned content. JavaScript is used to analyze the returned data and process returned messages. JavaScript is used to inject the new content into the HTML using the DOM API and to modify the CSS.
26. Does JavaScript required compulsory?
Yes, if you plan to develop new AJAX functionality for your web application you have to know at least Javascript.
27. What is the difference between proxied and proxyless calls?
Proxied calls are made through stub objects that mimic your PHP classes on the JavaScript side. E.g., the helloworld class from the Hello World example. Proxyless calls are made using utility javascript functions like HTML_AJAX.replace() and HTML_AJAX.append().
28. Are there any frameworks available to help speedup development with AJAX?
There are several browser-side frameworks available, each with their own uniqueness... Google or Live it.
30. How do I debug JavaScript?
There are not that many tools out there that will support both client-side and server-side debugging. VS 2008 enables directly, if you use other than VS 2008 you need to Disable Script Debugging from IE then you able to debug, other alternate way is using alert method.
31. Are Ajax applications easier to develop than traditional web applications?
I say yes but not necessarily. Ajax applications inevitably involve running complex JavaScript code on the client. Nowadays we have more tools and lot of support.
32. Does JUNIT support AJAX code?
Yes.
33. What Browsers does HTML_AJAX work with?
As of 0.3.0, all the examples that ship with HTML_AJAX have been verified to work with * Firefox 1.0+ * Internet Explorer 5.5+ (5.0 should work but it hasn't been tested) Most things work with * Safari 2+ * Opera 8.5+
34. Is Ajax just another name for XMLHttpRequest?
No. XMLHttpRequest is only part of the Ajax equation. XMLHttpRequest is the technical component that makes the asynchronous server communication possible; Ajax is our name for the overall approach described in the article, which relies not only on XMLHttpRequest, but on CSS, DOM, XML and other technologies.
35. How do I abort the current XMLHttpRequest?
Just call the abort() method on the request.
36. How do I get the XMLHttpRequest object?
Depending upon the browser... if (window.ActiveXObject) { // Internet Explorer http_request = new ActiveXObject("Microsoft.XMLHTTP"); } else if...
37. Are there any security issues with AJAX?
JavaScript is in plain view to the user with by selecting view source of the page. JavaScript can not access the local filesystem without the user's permission. An AJAX interaction can only be made with the servers-side component from which the page was loaded. A proxy pattern could be used for AJAX interactions with external services. You need to be careful not to expose your application model in such as way that your server-side components are at risk if a nefarious user to reverse engineer your application. As with any other web application, consider using HTTPS to secure the connection when confidential information is being exchanged.
38. Where can I find examples of AJAX?
www.asp.net/ajax or Google or Live it.
39. Is AJAX a programming language?
No. It is a library and technique.
40. Techniques for asynchronous server communication have been around for years. What makes Ajax a “new” approach?
What’s new is the prominent use of these techniques in real-world applications to change the fundamental interaction model of the Web. Ajax is taking hold now because these technologies and the industry’s understanding of how to deploy them most effectively have taken time to develop.