I
Ilyas
Hi all
I have the following in my .aspx
<asp:ScriptManager runat="server" ID="ScriptManager1" />
<asp:UpdatePanel runat="server" ID="UpdatePanel1">
<ContentTemplate>
<asp:Label runat="server" ID="lbl1" Text="Time will go
here..." />
</ContentTemplate>
</asp:UpdatePanel>
<asp:Button runat="server" id="btn1" OnClick="btn1_OnClick"
Text="Get time" />
and in my code behind I have:
protected void Page_Load(object sender, EventArgs e)
{
AsyncPostBackTrigger t = new AsyncPostBackTrigger();
t.ControlID = btn1.ID;
UpdatePanel1.Triggers.Add(t);
}
protected void btn1_OnClick(object sender, EventArgs e)
{
lbl1.Text = DateTime.Now.ToString();
}
Now when I click the button, the first request is made using ajax, if
I click again the next request does a full postback and this
alterntates everytime
Can anyone explain why? I want to add async triggers through code (I
know you can do it in the .aspx) but I dont want a full page postback
Many thanks
I have the following in my .aspx
<asp:ScriptManager runat="server" ID="ScriptManager1" />
<asp:UpdatePanel runat="server" ID="UpdatePanel1">
<ContentTemplate>
<asp:Label runat="server" ID="lbl1" Text="Time will go
here..." />
</ContentTemplate>
</asp:UpdatePanel>
<asp:Button runat="server" id="btn1" OnClick="btn1_OnClick"
Text="Get time" />
and in my code behind I have:
protected void Page_Load(object sender, EventArgs e)
{
AsyncPostBackTrigger t = new AsyncPostBackTrigger();
t.ControlID = btn1.ID;
UpdatePanel1.Triggers.Add(t);
}
protected void btn1_OnClick(object sender, EventArgs e)
{
lbl1.Text = DateTime.Now.ToString();
}
Now when I click the button, the first request is made using ajax, if
I click again the next request does a full postback and this
alterntates everytime
Can anyone explain why? I want to add async triggers through code (I
know you can do it in the .aspx) but I dont want a full page postback
Many thanks