First Asp.Net Ajax Program
Ajax introduces a revolutionary approach to web pages by enabling Partial-page rendering, which allows for updating specific portions of a webpage without requiring a complete page refresh. The following example illustrates the difference between Partial-page rendering and the traditional method of page updates within the same web page.
ScriptManager control
In order to use the capabilities of ASP.NET AJAX Extensions, the essential core component is the ScriptManager control. In almost every Ajax application, the usage of a ScriptManager control is imperative. In the provided example, we have included a ScriptManager control, an UpdatePanel control, two buttons (Ajax-Button and Non-Ajax-Button), and two label controls within a form.
UpdatePanel control
The first button, Ajax-Button, is situated within the UpdatePanel control area, while the second button, Non-Ajax-Button, is placed outside of the UpdatePanel control area. When running this application and clicking the Ajax-Button, you will observe that only the first label control is updated to display the current server time. Conversely, when clicking the Non-Ajax-Button, both label controls will be updated with the current server time.
This behavior occurs due to the placement of the first button (Ajax-Button) and the associated label control inside the UpdatePanel control area, which triggers Partial-page rendering. Consequently, only the portion of the webpage enclosed within the UpdatePanel is refreshed when the Ajax-Button is clicked. Conversely, when the Non-Ajax-Button is clicked, both labels are updated, as it operates in a traditional manner, resulting in a full page refresh or postback to the web server.
Default.aspxWhen you copy and paste the above Default.aspx code put the appropriate header like .. if you using c# add the following line at the top of Default.aspx
or if you r using vb.net add the following line at the top of Default.aspx
Conclusion
Ajax empowers developers to employ Partial-page rendering, updating specific portions of a webpage without requiring a complete refresh. By utilizing the ScriptManager control and UpdatePanel control, developers can selectively update content and enhance the user experience. The example provided demonstrates the distinction between Partial-page rendering and the conventional approach, illustrating how Partial-page rendering achieves targeted updates while minimizing the need for full page refreshes.