Problem With Client Ajax Request

5 posts, 0 answers
  1. Filipe Peixinho
    Filipe Peixinho avatar
    41 posts
    Member since:
    May 2006

    Posted 29 Nov 2010 Link to this post

    Greetings,
    I am currently using version control RadAjaxManager 2010.3.1109.35 with the following problem:

    I want to update a particular "asp: DropDownList" when the values of a "Telerik:RadMaskedTextBox" changed.

    For this purpose i’m using the client event "OnValueChanged" to trigger a Ajax request, however, this scenario only works one time.

     

    After the first ajax request, if i trigger the "OnValueChanged" again, the ajax request isn’t fired. I have done some debug and in the second time i trigger the event, the control RadAjaxManager in the client side is null.

     

    How do I solve this problem?

     

    Code executed in server side:

     

    protected void Adabas_AjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e)
      
    {
      
        string argument = (e.Argument);
      
        string[] arrayString = argument.Split(",".ToCharArray());
      
      
        string operacao = arrayString[0];
      
         if (operacao == "CarregarADABAS")
      
            {
      
                ptin.formare.lms.core.utilizadores.cnpj.gestaoCNPJ _gestcnpj = new ptin.formare.lms.core.utilizadores.cnpj.gestaoCNPJ("LMS_BD");
      
                DataTable lista_ADABAS = _gestcnpj.ListaADABASPorCNPJ(arrayString[1]);
      
                ddAdabas.Items.Clear();
      
                ddAdabas.DataSource = lista_ADABAS;
      
                ddAdabas.DataTextField = "ADABAS";
      
                ddAdabas.DataValueField = "ADABAS";
      
                ddAdabas.DataBind();
      
             }
      
    }

    Code executed in cliente side:

     

    <telerik:RadAjaxManager ID="Adabas" runat="server" onajaxrequest="Adabas_AjaxRequest">
      
        <AjaxSettings>
      
            <telerik:AjaxSetting AjaxControlID="Adabas">
      
                <UpdatedControls>
      
                    <telerik:AjaxUpdatedControl ControlID="ddAdabas" />
      
                </UpdatedControls>
      
             </telerik:AjaxSetting>
      
        </AjaxSettings>
      
    </telerik:RadAjaxManager>
      
       
      
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
      
        <script type="text/javascript">
      
        function CarregaListaADABAS (sender, args)
      
        {
      
          var message = args.get_newValue();
      
             message = message.replace(/[^a-zA-Z 0-9]+/g,'');
      
         var ajaxManager =  $find("<%= Adabas.ClientID %>"); //This value is null in the second time (event OnValueChanged)
      
            if(ajaxManager != null)
      
              {
      
                 ajaxManager.ajaxRequest('CarregarADABAS,'+ message);
      
              }
      
        }
      
        </script >
      
    </telerik:RadCodeBlock>
      
       
      
    <Telerik:RadMaskedTextBox ID="txt_cnpj" runat="server" Rows="1" UseEmbeddedScripts="False" Mask="##.###.###/####-##" TextWithLiterals="..-" CausesValidation="True" Width="125px" Height="11px" Skin="Outlook">
      
         <ClientEvents OnValueChanged="CarregaListaADABAS"/>
      
    </Telerik:RadMaskedTextBox>

     

    Regards

  2. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 29 Nov 2010 Link to this post

    Hello Filipe,

    Could you please specify if the issue is replicable in all browsers or in specific ones? And also, where is the code placed - in a regular aspx page, content page or user control?

    Regards,
    Iana
    the Telerik team
    Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Filipe Peixinho
    Filipe Peixinho avatar
    41 posts
    Member since:
    May 2006

    Posted 29 Nov 2010 Link to this post

    • Browser used: Internet Explorer 8 and Mozilla Firefox version 3.6.12
    • The code are in a user control
  5. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 01 Dec 2010 Link to this post

    Hi Filipe,

    In this case, is the user control dynamically loaded or declared statically on the page?
    However, I would suggest that you move the RadAjaxManager in the page markup as described in this article. Then in the user control you can use the GetCurrent(Page) static method of the RadAjaxManager class to get the instance of the manager either on the client and on the server. Furthermore in the user control Page_Load event handler, you should add a dynamic setting where the true RadAjaxManager updates the ddAdabas control and add handler for the AjaxRequest event.

    Give it a try and let me know how it goes.

    Greetings,
    Iana
    the Telerik team
    Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  6. Filipe Peixinho
    Filipe Peixinho avatar
    41 posts
    Member since:
    May 2006

    Posted 02 Dec 2010 Link to this post

    Hi.

    I tried as you suggested and it worked.

    Thank you very much for the help.

    Regards
    Filipe
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017