RadTextBox postback not firing after tabbing off

2 posts, 0 answers
  1. Aarsh
    Aarsh avatar
    192 posts
    Member since:
    Jun 2012

    Posted 22 Jun 2013 Link to this post

    Hello friends,

    I am using a RadTextBox, laying on a RadWindow and I want to make an ajax request from that control when the OnTextChange event is triggered. I am trying to use the following :
    ScriptManager : This is the content page and the master page has got a script manager as below:
    • <body>
          <form id="form1" runat="server">
          <telerik:RadScriptManager ID="scriptSchMaster" runat="server" EnablePartialRendering="true"
              EnableScriptCombine="true" OnAsyncPostBackError="scriptSchMaster_AsyncPostBackError">
              <Scripts>
                  <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js">
                  </asp:ScriptReference>
                  <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js">
                  </asp:ScriptReference>
                  <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js">
                  </asp:ScriptReference>
              </Scripts>
          </telerik:RadScriptManager>
          <telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server">
          </telerik:RadStyleSheetManager>
          <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
          </telerik:RadAjaxManager>
          <telerik:RadSkinManager ID="RadSkinManager1" runat="server">
              <TargetControls>
                  <telerik:TargetControl ControlsToApplySkin="<Rad Controls>" Skin="<some valid skin name>" />
                  <telerik:TargetControl ControlsToApplySkin="<Rad Controls>" Skin="<some valid skin name>" />
                  ...
    .aspx code snippet

    <label>Product #</label><br />
    <telerik:RadTextBox ID="tbProductNumber" runat="server" Width="250" CssClass="upperCase"
            AutoPostBack="true" MaxLength="30" OnTextChanged="tbProductNumber_OnTextChanged"
            EmptyMessage="Required" EnableViewState="true"
            EmptyMessageStyle-CssClass="validatorText">
     
                <ClientEvents OnBlur="jsfun_tbProductOnBlur" />
     
    </telerik:RadTextBox>
     
    <asp:UpdatePanel ID="upCheckProductNumber" runat="server" UpdateMode="Always">
         <ContentTemplate>
            <asp:Label ID="lblCheckProductResult" runat="server"></asp:Label>
        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="tbProductNumber" EventName="TextChanged" />
        </Triggers>
    </asp:UpdatePanel><br />
    <label id="lblProductNumValidator"></label>


    .js code

    function jsfun_tbProductNumberOnBlur(sender, args) {
        elem_ProductNumber = $find('<%=tbProductNumber.ClientID %>');
        if (
                elem_ProductNumber.get_value() != null &&
                elem_ProductNumber.get_value() != undefined
            )
                    ProductNoEmpty = false;
                else
                    ProductNoEmpty = true;
     
                showErrors();
     
                //__doPostBack('', '');
    }


    .aspx.cs code snippet: (This is not being called)

    protected void tbProductNumber_OnTextChanged(object sender, EventArgs e)
    {
            lblCheckProductNumberResult.Text = "Hello Ajax!";
    }


    I tried something in a separate sample application and it seemed to be working for textbox and radtextbox, both ...

    .aspx content page

    <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
        <asp:ScriptManager runat="server">
        </asp:ScriptManager>
        <br />
        <asp:TextBox ID="TextBox1" runat="server" AutoPostBack="True" OnTextChanged="txtChanged"></asp:TextBox>
        <telerik:RadTextBox ID="radTextBox1" runat="server" AutoPostBack="true" OnTextChanged="txtChanged">
        </telerik:RadTextBox>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="TextBox1" EventName="TextChanged" />
                <asp:AsyncPostBackTrigger ControlID="radTextBox1" EventName="TextChanged" />
            </Triggers>
        </asp:UpdatePanel>
        <br />
        <input id="Text1" type="text" /><br />
        <br />
        <asp:Button ID="Button1" runat="server" Text="Button" />
        <br />
    </asp:Content>


    code behind
    public partial class WebForm1 : System.Web.UI.Page
        {
            protected void Page_Load(object senderEventArgs e)
            {
     
            }
            protected void txtChanged(object senderEventArgs e)
            {
                Label1.Text = DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fff tt");
                
            }
        }

    Any help 'd be appreciated ...

    Thanks,
    -Aarsh
  2. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 25 Jun 2013 Link to this post

    Hi Aarsh,

    I have examined your code and spotted that the JavaScript event handler that you are trying to use has different than the declarated one.
    <ClientEvents OnBlur="jsfun_tbProductOnBlur" />

    function jsfun_tbProductNumberOnBlur(sender, args) {

    This will result in JavaScript exception and the Ajax Callback will not happen.

    I suppose it could be a copy-paste error during your posting so please confirm that you have enabled Script Debugging in your browser and there is no JavaScript error if this is not the source of the problem.

    Regards,
    Vasil
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top