I've posted this in another forum on here by accident, I think I've put this into the correct forum now.
I want to know if it is possible to update a label that is wrapped in a RadAjaxPanel using code behind? I.e.:
telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" height="200px" width="300px"> <asp:Label ID="Connections" runat="server" Text="0"></asp:Label> </telerik:RadAjaxPanel>
Code behind ( C# code ):
Connections.text = "100";
I can't get this to work unless I do a postback which is obviously not what I want.
I know this will probably work if I have a timer event and do it in that, but don't want to use one.
Any help is much appreciated.
5 Answers, 1 is accepted
Thanks for reply and information. I've quickly looked at the example it gives but still unsure as to how I'd implement this.
I've used a timer for now to cause the event:
asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>Connections :<asp:Label ID="Connections" runat="server" Text="0"></asp:Label><br />
<asp:Timer ID="Timer1" runat="server" Interval="1000" ontick="Timer1_Tick"></asp:Timer></ContentTemplate>
What I really want is when a user connects to a socket I have listening for connections, is to update the Connections.text. My timer code:
protected void Timer1_Tick(object sender, EventArgs e)
if (server != null)
this.Connections.Text = server.nClientConnections.ToString();
I'd like this event to be called when a user connects, how can this be done with the OnAjaxRequest event? I guess I need to replace the UpdatePanel with RadAjaxPanel?
I've now got this code:
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" onajaxrequest="RadAjaxManager1_AjaxRequest"></telerik:RadAjaxManager><asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
And in my C# :
protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
this.Label1.Text = "100";// server.nClientConnections.ToString();
I raise this event in my code when a user connect:
The event gets raised, but the Label1.text is not updated...
What am I doing wrong?
Please try the following code to initiate AjaxRequest on PageLoad:
window.onload = function()
<%= RadAjaxManager1.ClientID %>.AjaxRequest("InitialPageLoad");
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
I don't think it is possible to update a label without raising some kind of event, whether this be a timer event or a button click event.
All the examples I have seen with updating of labels etc, always have an onclick button event associated with them, obviously this is not what I want.
I guess I will just have to use a timer event :-(