Day Dreaming

"A daydream is a visionary fantasy experienced while awake, especially one of happy, pleasant thoughts, hopes or ambitions."[Ref:Wikipedia]

DAY 1 : AJAX - Introduction and Components

AJAX
Why and What is ASP.NET Ajax?
**Disclaimer: I have got these information from varied sources and for some of them
have been referenced from Sams teach yourself ASP.NET Ajax in 24 hrs. **

AJAX (Asynchronous JavaScript) mainly allows you to perform partial updates to the page and also asynchronous postback which gives the users interactive and slick feel. Now, With AJAX, a JavaScript can communicate directly with the server, with the XMLHttpRequest object. With this object, a JavaScript can trade data with a web server, without reloading the page. You can find tutorial to AJAX at w3schools which takes you to all the basic concepts you need to know about AJAX. To provide partial page rendering we have two other options first using IFrame but it is a synchronous operation that causes the portion of the page to reload and flicker. And second, the client-side script needs to be written for hiding or showing the IFrame, when dynamic loading of a portion of the page is to be handled on an event. The second method using XMLHttpRequest object but isn’t the best, as the logic has to be moved from the server to client. Also, the browser incompatibility issues come into the picture when using the XMLHttp protocol. Thus using update panel and other ASP.NET Ajax is the best option.
How AJAX works?
Important blocks or services for which ASP.NET 2.0 has support:
- The Membership API - The Membership API in ASP.NET 2.0 enables you to manage the users and roles of an application.
- The Profile API -The ASP.NET 2.0 Profile API can be used to store profile information for both authenticated and anonymous users and make it available to the application for the user’s subsequent visits to the application.
- The Personalization API - The ASP.NET 2.0 Personalization API enables you to personalize your application seamlessly. You can use this API to customize the user profiles, themes, error pages of your application
The ASP.NET AJAX server extensions framework includes the following components:
- Application Services Bridge - This component is used to provide access to the application services available as part of ASP.NET 2.0 from client-side scripts. The basic services provided by this bridge include, but are not limited to, the following:
o User authentication using the Membership API
o Storage of user’s data using the Profile API
- The Web Services Bridge - The web services bridge is used to consume external web services from the client side in an Ajax-enabled web application. Web services have already been explained in the previous section. The web services bridge makes use of the JSON serializer, JavaScript proxies, and the .asbx files or the bridge files to call the web services.

ASP.NET AJAX Controls-
- Timer
- ScriptManager
- ScriptManagerProxy
- UpdateProgress
- UpdatePanel

Timer - Using the Timer control, you can set a timer for your web page. You can ensure that the web page can post back to the web server after a specified interval of time. You can use the Interval property of this control to set an interval in milliseconds, after which the web page will refresh itself. Once this interval elapses, the control fires a post back to the web server. This is how the mark-up code of a typical Timer control looks:


Script Manager – (Brain of an Ajax-Enabled Web Page) - Manages Microsoft ASP.NET 2.0 Ajax extensions script libraries and script files, partial-page rendering, and client proxy class generation for web and application services.
Script ManagerProxy - ScriptManagerProxy control enables you to add scripts and services that are specific to nested components. You should have a ScriptManager control in a web page that has a ScriptManagerProxy control, or else an InvalidOperationException error. If you need to register a script that is not part of Script manager control we can use Script ManagerProxy to add these scripts.



- Update Progress Control – (Displaying Progress Status During Partial Updates) - The UpdateProgress control can be used to display the progress status when using partial-page rendering in an Ajax-enabled ASP.NET web page.
...
- The UpdatePanel Control – (Facilitating Partial Page Updates) - The UpdatePanel control included as a part of the Ajax server extensions framework is used to update only a specified portion of the web page. This feature is what is commonly known as partial-web page rendering.

Setting the UpdateMode property to Conditional is advisable because it improves the performance of the web page considerably by sending only the data that is to be updated in the page.
A trigger is an event that causes the UpdatePanel to refresh its content. This event can be generated by any control in the form. There are two types of triggers:
- AsyncPostBackTrigger - The AsyncPostBackTrigger fires an asynchronous postback event on the UpdatePanel control. The child control’s postback of the UpdatePanel by default fires this trigger. There are two attributes associated with the AsyncPostBackTrigger: ControlID and EventName.
- PostBackTrigger - There might be situations where a button is clicked in an UpdatePane, and it requires the entire web page to be posted back. In such scenarios, we can go ahead with the PostBackTrigger. This trigger does not have an EventName property.
You can have one and only one ScriptManager control in your Ajax-enabled web page.

0 comments: