Bug with RadTextBox autopostback

4 posts, 1 answers
  1. EmpowerIT
    EmpowerIT avatar
    117 posts
    Member since:
    Jun 2007

    Posted 12 Mar 2008 Link to this post

    Hi,
    Im using the latest version of the prometheus controls. I've come across a problem where a radtextbox does not fire the textchanged event all the time.

    I've managed to reproduce the problem on a simple page as follows:

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="RadTextboxAutoPostbackBug.aspx.cs" Inherits="RadTextboxAutoPostbackBug" %> 
     
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
     
    <html xmlns="http://www.w3.org/1999/xhtml" > 
    <head runat="server"
        <title>Untitled Page</title> 
    </head> 
    <body> 
        <form id="form1" runat="server"
            <asp:ScriptManager ID="ScriptManager1" runat="server"
            </asp:ScriptManager> 
        <div> 
            <telerik:radtextbox id="RadTextBox1" runat="server" autopostback="True" ontextchanged="RadTextBox1_TextChanged" 
                textmode="SingleLine" width="125px"></telerik:radtextbox> 
            <telerik:radtextbox id="RadTextBox2" runat="server" autopostback="True" ontextchanged="RadTextBox2_TextChanged"></telerik:radtextbox> 
            <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label></div
            <telerik:radajaxmanager id="RadAjaxManager1" runat="server" defaultloadingpanelid="RadAjaxLoadingPanel1"><AjaxSettings> 
                <telerik:AjaxSetting AjaxControlID="RadTextBox1"
                    <UpdatedControls> 
                        <telerik:AjaxUpdatedControl ControlID="Label1" /> 
                    </UpdatedControls> 
                </telerik:AjaxSetting> 
                <telerik:AjaxSetting AjaxControlID="RadTextBox2"
                    <UpdatedControls> 
                        <telerik:AjaxUpdatedControl ControlID="Label1" /> 
                    </UpdatedControls> 
                </telerik:AjaxSetting> 
    </AjaxSettings> 
    </telerik:radajaxmanager> 
            <telerik:radajaxloadingpanel id="RadAjaxLoadingPanel1" runat="server" height="75px" 
                width="75px"
            <img src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading.gif") %>' alt="Loading..." style="border:0px;" /> 
        </telerik:radajaxloadingpanel> 
        </form> 
    </body> 
    </html> 
     

    The code behind:

    using System; 
    using System.Data; 
    using System.Configuration; 
    using System.Collections; 
    using System.Web; 
    using System.Web.Security; 
    using System.Web.UI; 
    using System.Web.UI.WebControls; 
    using System.Web.UI.WebControls.WebParts; 
    using System.Web.UI.HtmlControls; 
     
    public partial class RadTextboxAutoPostbackBug : System.Web.UI.Page 
        protected void Page_Load(object sender, EventArgs e) 
        { 
     
        } 
        protected void RadTextBox1_TextChanged(object sender, EventArgs e) 
        { 
            Label1.Text = DateTime.Now.ToString() + ": TextBox1 Changed"
        } 
        protected void RadTextBox2_TextChanged(object sender, EventArgs e) 
        { 
            Label1.Text = DateTime.Now.ToString() + ": TextBox2 Changed"
        } 

    The autopostback will work the first time you change the text for both text boxes. The next time you try to change it, it will not fire, and it will also revert back to the old text that existed in the textbox.

    Thanks,
  2. Answer
    Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 13 Mar 2008 Link to this post

    Hi EmpowerIT,

    You need to add the textboxes as updated controls in the AjaxSettings too. Now they are not updated and the TextChanged event is not fired. So the label is not updated too. Please try with the following settings of the AjaxManager and let us know if it helps.

    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" EnableAJAX="true">  
        <AjaxSettings> 
            <telerik:AjaxSetting AjaxControlID="RadTextBox1">  
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="Label1" LoadingPanelID="RadAjaxLoadingPanel1" /> 
                    <telerik:AjaxUpdatedControl ControlID="RadTextBox1" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
            <telerik:AjaxSetting AjaxControlID="RadTextBox2">  
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="Label1" LoadingPanelID="RadAjaxLoadingPanel1" /> 
                    <telerik:AjaxUpdatedControl ControlID="RadTextBox2" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
        </AjaxSettings> 
    </telerik:RadAjaxManager> 


    Sincerely yours,
    Iana
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Andrew Watt
    Andrew Watt avatar
    6 posts
    Member since:
    Oct 2009

    Posted 16 Nov 2009 Link to this post

    I have the same problem with the radtextbox ontextchanged event. I am using an ajaxmanager just like in this example and I have tried the solution proposed by Lana but it does not seem to work for me.

    My situation is that I am using the text in the textbox as criteria for a search. I have a radgrid which shows the search results, bound to an objectdatasource. The server side event fires every time but seems to get lost in the ether every time except for the first time.


            protected void txtBusinessName_OnTextChanged(object sender, EventArgs args)
            {
                grdSearchResults.DataBind();
            }




                    <telerik:RadGrid ID="grdSearchResults" runat="server" DataSourceID="odsBusinessNameMatches"
                        GridLines="None" AllowPaging="True" AllowSorting="True" Width="100%" ShowStatusBar="True">
                        <MasterTableView DataSourceID="odsBusinessNameMatches" AutoGenerateColumns="false">
                            <RowIndicatorColumn>
                                <HeaderStyle Width="20px"></HeaderStyle>
                            </RowIndicatorColumn>
                            <ExpandCollapseColumn>
                                <HeaderStyle Width="20px"></HeaderStyle>
                            </ExpandCollapseColumn>
                            <Columns>
                                <telerik:GridClientSelectColumn Reorderable="False" UniqueName="ClientSelectColumn">
                                    <HeaderStyle Width="20px"></HeaderStyle>
                                </telerik:GridClientSelectColumn>
                                <telerik:GridBoundColumn DataField="BusinessName" HeaderText="Business Name" SortExpression="BusinessName"
                                    UniqueName="BusinessName">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="Nature" HeaderText="Nature" SortExpression="Nature"
                                    UniqueName="Nature">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="Type" HeaderText="Type" SortExpression="Type"
                                    UniqueName="Type">
                                </telerik:GridBoundColumn>
                            </Columns>
                        </MasterTableView>
                        <ClientSettings>
                            <Selecting AllowRowSelect="True" />
                            <ClientEvents OnRowSelected="RowSelected" />
                        </ClientSettings>
                    </telerik:RadGrid>

                        <telerik:RadTextBox ID="txtBusinessName" runat="server" Width="385px" OnTextChanged="txtBusinessName_OnTextChanged"
                            AutoPostBack="True">
                        </telerik:RadTextBox>

            <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
                <AjaxSettings>
                    <telerik:AjaxSetting AjaxControlID="txtBusinessName">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="grdSearchResults" />
                            <telerik:AjaxUpdatedControl ControlID="txtBusinessName" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                </AjaxSettings>
            </telerik:RadAjaxManager>

    EmpowerIT - did this solution work for you?


  5. Andrew Watt
    Andrew Watt avatar
    6 posts
    Member since:
    Oct 2009

    Posted 16 Nov 2009 Link to this post

    I found my problem:

    this should never have been part of the grid:<ClientEvents OnRowSelected="RowSelected" />
Back to Top