PC Review


Reply
Thread Tools Rate Thread

Add triggers to an update panel in code how?

 
 
Ilyas
Guest
Posts: n/a
 
      28th Aug 2008
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
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Html code of child control on Update Panel doesnot appear at runtime. chandan Microsoft ASP .NET 0 30th Sep 2008 07:19 AM
ExecutionEngineException -> Code sample that triggers EEE =?Utf-8?B?VFQgKFRvbSBUZW1wZWxhZXJlKQ==?= Microsoft C# .NET 14 6th Oct 2005 02:15 PM
Email triggers code to run? =?Utf-8?B?QWxleA==?= Microsoft Outlook VBA Programming 0 18th Oct 2004 11:05 PM
DoEvents triggers previous code =?Utf-8?B?Sm9obiBC?= Microsoft Excel Programming 1 15th Mar 2004 02:06 PM
code for lookup,& triggers. derek Microsoft Excel Programming 3 22nd Jul 2003 05:04 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:39 AM.