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

Problem With Client Ajax Request

4 Answers 74 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Filipe Peixinho
Top achievements
Rank 1
Filipe Peixinho asked on 29 Nov 2010, 12:04 PM

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

4 Answers, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 29 Nov 2010, 04:30 PM
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.
0
Filipe Peixinho
Top achievements
Rank 1
answered on 29 Nov 2010, 07:47 PM
  • Browser used: Internet Explorer 8 and Mozilla Firefox version 3.6.12
  • The code are in a user control
0
Iana Tsolova
Telerik team
answered on 01 Dec 2010, 12:38 PM
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.
0
Filipe Peixinho
Top achievements
Rank 1
answered on 02 Dec 2010, 03:15 PM
Hi.

I tried as you suggested and it worked.

Thank you very much for the help.

Regards
Filipe
Tags
Ajax
Asked by
Filipe Peixinho
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Filipe Peixinho
Top achievements
Rank 1
Share this question
or