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

Second ajax call on page

4 Answers 192 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
ewart
Top achievements
Rank 1
ewart asked on 09 Jul 2008, 09:06 AM
Hi, I'm trying out the futures build  2008.2.708.20  and converting some existing pages.

When I input something the first time (into either text box), everything works fine.  tab to other field, and the second input to the other textbox the $find call always returns null.

Code wrapped in a <radcodeblock>

This is within a user control loaded onto a page. (using a standard bit of code to load the user control which hasn't changed for 100+ pages)

// Point to text box  
var textBox1Element = document.getElementById("ControlsRegistration_rmtEMail");  
var textBox2Element = document.getElementById("ControlsRegistration_rmtUsername");  
 
// When the textbox looses focus, call AJAX function  
textBox1Element.onblur = sendData;  
textBox2Element.onblur = sendData;  
 
function sendData()  
{  
   var srcElement = window.event.srcElement;                               // Point to control  
   var ajaxManagerObject = $find("<%= myajax.ClientID %>");                // Locate AJAX Object  
            
   ajaxManagerObject.ajaxRequest(srcElement.id + ":" + srcElement.value);  // Process AJAX Request passing control name, value and UTC offset  

I noticed this code was producng some errors in the FF console (abuot srcElement), so I created a simpler version
where I have onblur="func();" assigned in the <asp:textbox>..  still no joy with ajax though:
 
function bEmail()  
{  
    var ajaxManagerObject = $find("<%= myajax.ClientID %>");// Locate AJAX Object     
   var textBox1Element = document.getElementById("ControlsRegistration_rmtEMail");  
    ajaxManagerObject.ajaxRequest(textBox1Element.id + ":" + textBox1Element.value);  // Process AJAX Request passing control name, value and UTC offset     
}    
 
 
function bUser()  
{  
    var ajaxManagerObject = $find("<%= myajax.ClientID %>");// Locate AJAX Object     
    var textBox2Element = document.getElementById("ControlsRegistration_rmtUsername");  
    ajaxManagerObject.ajaxRequest(textBox2Element.id + ":" + textBox2Element.value);  // Process AJAX Request passing control name, value and UTC offset     
}    
 

any ideas?

4 Answers, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 14 Jul 2008, 11:00 AM
Hi ewart,

This is indeed a strange issue and unfortunately from the provided details I am not able to determine the exact reason for the abnormality you encountered.

Does adding the user control statically on the page produces the desired result? Additionally, note that in user control scenario you need to utilize the GetCurrent static method of RadAjaxManager in order to get reference to it:

http://www.telerik.com/DEMOS/ASPNET/Prometheus/Ajax/Examples/Manager/UserControl/DefaultCS.aspx

Best regards,
Stephen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Chagit
Top achievements
Rank 1
answered on 30 Jul 2008, 01:48 PM
Hi.
I have the almost same problem. It discussed in http://www.telerik.com/community/forums/thread/b311D-bakhmm.aspx .

I use the following script:
<script language="javascript" type="text/javascript">  
  function LoadFromDetails(key)  
  {  
    <%= ajaxManager.ClientID %>.AjaxRequest(key);  
  }  
</script> 

When I call the function in the second time I get the js error "srcElement is null or not an object".

Do you have any idea?
Thanks
0
Sebastian
Telerik team
answered on 30 Jul 2008, 02:12 PM
Hello Chagit,

If you do not mind we will provide an answer for you in the other forum post you linked in your message.

Best regards,
Stephen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
ewart
Top achievements
Rank 1
answered on 30 Jul 2008, 09:10 PM
For anyone else in the same boat..  In the end I gave up on getting this working in a dynamically loaded user control. 

I moved the code to a ASPX page instead and the exact same code worked fine.  The code had also worked fine in a user control prior to my upgrade to promethesus so it must have been something I needed to do differently in the new env.  Other user controls converted ok but the majority of those did not use an ajax manager on the page, so it was most likely something to do with that... and I don't think it was the obvious new '1 ajax manager only rule'  as I did not have two ajax managers in the load sequence.

cheers
  ewart
Tags
Ajax
Asked by
ewart
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
Chagit
Top achievements
Rank 1
ewart
Top achievements
Rank 1
Share this question
or