AJAX ගැන දන්නව ඇති නේ. ඉතින් ASP Pages, වලට AJAX ability එක ලබා දෙන්න Update Panel පාවිච්චි කරනවා.
Update Panel එක ඇතුලෙ තියන දේවල්, Separately render වෙනවා, Page එක reload වෙන්නෙ නැතිව.
ඊලඟට, Update Panel එක refresh වෙන්නෙ panel එක ඇතුලෙ තියන control එකකින් Postback එකක් ආවෙත් හරි, trigger එකට add කරල තියන control එකකින් Postback එකක් ආවෙත් හරි විතරයි.
Update Panel එක use කරන්න නම් ScriptManager control එකත් ඕන වෙනවා.
Example එකක්ද? මෙන්න ... මේක ගත්තෙ නම් මෙතනින්
Update Panel එක ඇතුලෙ තියන දේවල්, Separately render වෙනවා, Page එක reload වෙන්නෙ නැතිව.
ඊලඟට, Update Panel එක refresh වෙන්නෙ panel එක ඇතුලෙ තියන control එකකින් Postback එකක් ආවෙත් හරි, trigger එකට add කරල තියන control එකකින් Postback එකක් ආවෙත් හරි විතරයි.
Update Panel එක use කරන්න නම් ScriptManager control එකත් ඕන වෙනවා.
Example එකක්ද? මෙන්න ... මේක ගත්තෙ නම් මෙතනින්
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>UpdatePanel</title> </head> <body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server" /> <asp:UpdatePanel runat="server" id="UpdatePanel" updatemode="Conditional"> <Triggers> <asp:AsyncPostBackTrigger controlid="UpdateButton2" eventname="Click" /> </Triggers> <ContentTemplate> <asp:Label runat="server" id="DateTimeLabel1" /> <asp:Button runat="server" id="UpdateButton1" onclick="UpdateButton_Click" text="Update" /> </ContentTemplate> </asp:UpdatePanel> <asp:UpdatePanel runat="server" id="UpdatePanel1" updatemode="Conditional"> <ContentTemplate> <asp:Label runat="server" id="DateTimeLabel2" /> <asp:Button runat="server" id="UpdateButton2" onclick="UpdateButton_Click" text="Update" /> </ContentTemplate> </asp:UpdatePanel> </form> </body> </html>
Cording වලට මේ method එකත් add කරන්න.protected void UpdateButton_Click(object sender, EventArgs e) { DateTimeLabel1.Text = DateTime.Now.ToString(); DateTimeLabel2.Text = DateTime.Now.ToString(); }