After successful creation of “Hello World” now I am going to describe how to write Hello World in Ajax framework/Ajax extension. I have enhanced earlier Hello World code to describe Hello World in Ajax. As previous I am attaching codes at below look carefully and try to find out difference with earlier.
In these codes I have highlighted sections with 1, 2 and 3. Section 1 and 2 are related with Ajax and 3 for timer. Section 1 is “ScriptManager” enables Ajax functionality in page. Remember in a page only one ScriptManager is permitted. If you add multiple ScriptManager then it will trough an error. Even for Master page scenario multiple ScriptManager is not permitted.
Section 2 is “UpdatePanel”. UpdatePanel is a wrapper of Ajax enabled sections. Using UpdatePanel we can declare that section is Ajax enable and can work asynchronously. Within UpdatePanel I have taken ContentTemplate, which actually holding all update sections.
Section 3 has used to create a timer in page. This timer executes for every 1000 milliseconds, which means in every 1 second and it picks system time from backend and shows in browser. If you check carefully in browser then you will find to get time from backend no post back is happening.
In backend section there has no major change for Ajax, in fact no change is there. Just I have added a section to get system time using C# codes. To get current time I have used DateTime Structure and have picked up current system time.
Full backend codes are as below:
When this project runs in browser then it looks like below:















