Check the code below with AJAX and without AJAX
Case 1 with AJAX
In this we added the following controls
1. Script Manager 2. Ajax Update Panel with Trigger and Content Template 3. Button
In this case, you will notice that when you click the button, the controls outside the Update Panel will not be updated. This means that the controls inside the Update Panel will be updated when the button is clicked. This means that the full page will not be refreshed. I hope this fulfills your requirement ....
Exit
The date outside the update panel will not be updated, and the date inside the update panel will only be updated because it is located inside the update panel, so the full page will not be updated.
Source
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default4.aspx.cs" Inherits="Default4" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <%=DateTime.Now %> <br /> <asp:ScriptManager ID="scr" runat="server"> </asp:ScriptManager> <asp:UpdatePanel ID="Upd" runat="server" UpdateMode="Conditional"> <ContentTemplate> <%=DateTime.Now %> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="btn" EventName="Click" /> </Triggers> </asp:UpdatePanel> <asp:Button ID="btn" runat="server" Text="Click Me" /> </div> </form> </body> </html>
Case 2 without AJAX
In the example below, the date will also be updated, but this time page will be completely updated due to the lack of Update Panel <% @Page Language = "C #" AutoEventWireup = "true" CodeFile = "Default4.aspx.cs" Inherits = "Default4"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <%=DateTime.Now %> <asp:Button ID="btn" runat="server" Text="Click Me" /> </div> </form> </body> </html>
I hope this article helps you understand the quick basics.
source share