This is a migrated thread and some comments may be shown as answers.

Ajax cannot update the result of Label

1 Answer 137 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
wu asked on 23 Oct 2010, 03:02 PM
i read and made a similar demo, when client-side call
the TextBoxCustomAjax function to use Ajax send the request to server, server-side event RadAjaxManager1_AjaxRequest can be fired, and Label1.Text also updated value, but client-side cannot see any the updated result, why? i'm using RadControls 2010 for Ajax and VS 2010, these are my full demo code:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AddAjaxToHtmlElement.aspx.cs" Inherits="AddAjaxToHtmlElement"  %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">

<html xmlns="">
<head runat="server">
    <telerik:RadStyleSheetManager id="RadStyleSheetManager1" runat="server" />
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
            <%--Needed for JavaScript IntelliSense in VS2010--%>
            <%--For VS2008 replace RadScriptManager with ScriptManager--%>
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
    <script type="text/javascript">
        //Put your JavaScript code here.
        function TextBoxCustomAjax(eventArgs) {
            $find("<%=RadAjaxManager1.ClientID %>").ajaxRequest(eventArgs);
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" >

        <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" Height="200px" Width="300px">
             <asp:Label ID="Label1" runat="server" Text="Label1" /><br />
             <asp:TextBox ID="TextBox1" runat="server"
                 onkeyup="TextBoxCustomAjax('TextBox1');" type="text" /> <br />

using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Data;
using System.Configuration;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Telerik.Web.UI;

public partial class AddAjaxToHtmlElement : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)
        RadAjaxManager1.AjaxRequest += RadAjaxManager1_AjaxRequest;
    protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
        if (e.Argument == TextBox1.ClientID)
            Label1.Text = TextBox1.Text;
            Page.Title = TextBox1.Text;
  note :
            Label1.Text = TextBox1.Text;
            Page.Title = TextBox1.Text;
    Page.Title can be updated, but Label1.Text cannot be updated!!!

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 26 Oct 2010, 01:57 PM
Hello Wu,

Since you are using RadAjaxManager's ajaxRequest() client-side method to initiate the ajax, you need to add settings for it to update the Label:
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" >
            <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                    <telerik:AjaxUpdatedControl ControlID="Label1" />
Note that it is not recommended to use both RadAjaxPanel and RadAjaxManager to ajaxify the same controls so you can remove the panel from your markup.

I also recommend you to read the following help article:

Kind regards,
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question