Simple Ajax with .NET
Adding Ajax to an application is simple and easy! Ajax is a powerful tool and can make your application look and feel great!
First let’s start by adding a “Script Manager” to the page, now we only have to add this once so it’s best placed in your Master page. The Script Manager needs to be placed between the form tags on your page like so:
1 2 3 4 | <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> </form> |
After that, we can now add Ajax to an item. Below I have added an “Update Panel” to a list view. Now every action that list view makes will be way of HTTP Requests “Ajax”!
1 2 3 4 5 6 7 8 | <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:ListView ID="ListView1" runat="server" DataKeyNames="PostID" DataSourceID="ObjectDataSource1"> ' Your code here... </asp:ListView> </ContentTemplate> </asp:UpdatePanel> |


