I have had a ASP.NET page. Now I want to experiemt with the AJAX function. So first I drop aScriptManager and then aUpdatePanel onto the .aspx. After that, I further drag a label(Label1) and a button inside it and in a additon, I also drag a label(Label2) outside the UpdatePanel.
Inside the page_load event handler is:
Label1.Text = DateTime.Now.ToString();
Label2.Text = DateTime.Now.ToString();
However, when I click the button, two labels are updated as if a normal postback. In other words, the partial-update does not work.
What details do I miss so that the partial-update function do not work properly?
Thanks in advance.
Ricky.
Try this way..
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
//Place the Label within the Update panel Content template
<asp:Label ID="Label1" runat="server" Style="position: relative" Text="Label"></asp:Label>
</ContentTemplate>
//Add the trigger attribute and add as shown
<Triggers>
<asp:AsyncPostBackTrigger ControlID ="Button1" EventName ="Click" />
</Triggers>
</asp:UpdatePanel>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Style="left: 128px;
position: relative; top: 48px" Text="Button" /></div>
</form>
Thats all.
Any questions still, let me know
Sri
Hi, sridhar. After copying the web.config from an "ASP.NET AJAX-Enabled Web site" to my website. Everything got all right.
Anyway thanks for your reply.
Regards,
Ricky.
No comments:
Post a Comment