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

.ajaxrequest method not found

16 Answers 608 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Sharif
Top achievements
Rank 1
Sharif asked on 20 Jan 2009, 01:41 AM
Good evening,

I'm trying to upgrade an exsiting project from an older version of Rad Controls to Q3 2008 (2008.3.1105.20 to be precise).  I've carefully read all the backwards compatability and upgrade pages, however I still can't get my RadAjaxManager to make a server call using javascrip.   My default aspx code is shown below.   My first request fails witht the following message: Microsoft JScript runtime error: Object doesn't support this property or method

I've included the script manager at the very top
I've surrounded my javascript with the codeblock tag
made sure my javascript is in the form (not outside of it)

The first request that occurs is near the bottom in the ResetTimer() function.  Once that works I can move on to changing the rest of the code.  It just passes the string  "keepalive" as the argument.

I've tried to declare the AjaxManager in every possible way but I still can't get it to work.  I'm sure it's something simple but I am out of ideas.  Anyone see the problem?

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %> 
<%@ 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></title
    <link href="StyleSheet.css" rel="stylesheet" type="text/css" /> 
</head> 
<body style="margin: 0px" background="Images/<%=Application("Logo")%>" onload="javascript:Login();" onunload="javascript:CloseOut();" > 
    <form id="form1" runat="server">  


   <Telerik:RadScriptManager ID="RadScriptManager1" runat="server" /> 
    
   <!-- Rad Menu  -------------> 
        <div style="position:absolute; z-index:90000;"
         
        <Telerik:RadMenu ID="RadMenu1" runat="server" Width="99%" AppendDataBoundItems="True" CollapseDelay="1500" Skin="Gray"  CollapseAnimation-Type="None" OnClientItemClicked="clickHandler"   > 
            <Items> 
                <Telerik:RadMenuItem  Text="Tools"  runat="server" > 
                    <Items> 
                         
                        <Telerik:RadMenuItem Text="Log in"   NavigateUrl="javascript:Login();" runat="server" > 
                        </Telerik:RadMenuItem> 
                             
                        <Telerik:RadMenuItem  Visible="False"  Text="Log out" NavigateUrl="javascript:Logout();" runat="server"
                        </Telerik:RadMenuItem> 
                              
                        <Telerik:RadMenuItem Visible="False"  Text="Change Password" runat="server" NavigateUrl="javascript:ShowPass();"
                        </Telerik:RadMenuItem> 
                     
                    </Items> 
                </Telerik:RadMenuItem> 
            </Items> 
            <CollapseAnimation Type="None" Duration="200" /> 
        </Telerik:RadMenu> 
   </div> 
    
   <script type="text/javascript">    
    function clickHandler(sender, eventArg)    
        {        
            if (eventArg.Item.Items.length == 0 ) 
            {        
            i = eventArg.Item.Menu.Close(); 
            } 
        }        
    </script>   
 
 
   <!-- Rad Menu  -------------> 
         
         
        <Telerik:RadAjaxManager id="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest" > 
            <AjaxSettings> 
                <Telerik:AjaxSetting AjaxControlID="RadAjaxManager1"
                    <UpdatedControls> 
                        <Telerik:AjaxUpdatedControl ControlID="RadMenu1" /> 
                    </UpdatedControls> 
                </Telerik:AjaxSetting> 
            </AjaxSettings> 
        </Telerik:RadAjaxManager> 
    
    
        <Telerik:RadAjaxLoadingPanel id="AjaxLoadingPanel1" Runat="server" height="75px" width="75px"
            <asp:Image ID="Image1" runat="server" AlternateText="Loading..." ImageUrl="~/RadControls/Ajax/Skins/Default/Loading.gif" /> 
        </Telerik:RadAjaxLoadingPanel> 
 
        <Telerik:RadWindowManager ID="RadWindowManager1" runat="server" Left="" Title="" Top="" Skin="Inox"
        <Windows> 
           <Telerik:RadWindow ID="Default" runat="server" ReloadOnShow="True"   Behavior="Minimize, Close, Move" Left="" Top="" style="display:none;" Behaviors="Minimize, Close, Move" InitialBehavior="None" NavigateUrl=""  /> 
           <Telerik:RadWindow ID="RackBuild" runat="server" NavigateUrl="Rack/RackBuild.aspx"  ReloadOnShow="True"   Behavior="Minimize, Close, Move" Left="" Top="" style="display:none;" Behaviors="Minimize, Close, Move" InitialBehavior="None"  /> 
           <Telerik:RadWindow ID="RackInquiry" runat="server" NavigateUrl="Rack/RackInquiry.aspx"  ReloadOnShow="True"   Behavior="Minimize, Close, Move" Left="" Top="" style="display:none;" Behaviors="Minimize, Close, Move" InitialBehavior="None"  /> 
        </Windows> 
        </Telerik:RadWindowManager> 
 
 
 
<telerik:RadCodeBlock ID="cb1" runat="server"
 
 
    <script type="text/javascript" > 
 
    var UserActive = false
    var usertimer = 0
    var timer = -1; 
    var currentTime = new Date() 
    var Minutes = currentTime.getMinutes() - 1 
    var Sess = ''
      
     
    document.body.onkeydown = function() {ResetTimer();}; 
    document.body.onclick = function() {ResetTimer();}; 
    document.onmousemove = function() {ResetTimer();}; 
 
 
    function OpenNewWindow(url, details) 
    { 
     var oManager = GetRadWindowManager();  
     var oNew = oManager.Open(url, details);  
    } 
     
     
    function SetWindow(ID, URL) 
    { 
    var oManager = GetRadWindowManager();  
    var oWnd = oManager.GetWindowByName(ID);  
    oWnd.SetUrl(URL); 
    oWnd.Show(); 
    } 
     
     
    function OpenWindow(ID) 
    {  
        //Getting RadWindow manager 
        var oManager = GetRadWindowManager();  
     
        try 
        { 
           //Success. Getting existing window DialogWindow using GetWindowByName 
            var oWnd = oManager.GetWindowByName(ID);  
            oWnd.Show(); 
           
        } 
        catch(err) 
        { 
            alert('This page is not found.\nI still have to build this screen.\nTry again later.'); 
        } 
 
    }  
     
     
    function ShowPass() 
    { 
     
    showModalDialog('password.aspx','Passed String','dialogHeight:195px;dialogWidth:550px;toolbar:no;directories=no;status=no;menubar=no;scroll:no;resizable=no;modal=yes') 
     
    } 
 
 
    function Login() 
    { 
     
         
        if ('<%=application("NPP")%>' != '') 
        { 
           alert('<%=application("NPP")%>'); 
        } 
     
        var x = '' 
        x = showModalDialog('Login.aspx','Passed String','dialogHeight:450px;dialogWidth:395px;toolbar:no;directories=no;status=no;menubar=no;scroll:no;resizable=no;modal=yes'); 
        if (x == undefined) 
        { 
        //alert('Log in Failed'); 
        } 
        else 
        { 
             window["<%= RadAjaxManager1.ClientID %>"].AjaxRequest('Login'); 
             UserActive = false
             usertimer = 0
             timer1 = window.setTimeout(CheckActive,1000); 
              
             if (x.split("|")[1]) { ForcePass(); } 
              
        }  
    } 
 
 
    function Logout() 
    { 
        var oManager = GetRadWindowManager(); 
        oManager.CloseAll(); 
        window["<%= RadAjaxManager1.ClientID %>"].AjaxRequest('Logout'); 
        Login() 
    } 
 
 
    function CloseOut() 
    { 
        if (Sess != '') 
        { 
        window.open('logout.aspx?S='+Sess,'mywin','width=450,height=150,toolbar=0,resizable=0'); 
        } 
    } 
 
 
 
    function ResetTimer()  
    { 
        UserActive = true
        currentTime = new Date() 
        if (Minutes != currentTime.getMinutes()) 
        { 
            Minutes = currentTime.getMinutes() 
            

  //PROBLEM IS HERE

//No matter how I declare this the method is not found
// I've used both capital and lower case "a" in the method
//tried document.getelementbyID
// tried $find

    var ajaxManager = <%= RadAjaxManager1.ClientID %>
            ajaxManager.AjaxRequest('KeepAlive'); 
             
           
           
        } 
    } 
     
     
 
 
    function CheckActive()  
    { 
        if (UserActive)   
        { 
            UserActive = false
            usertimer = 0 
            timer1 = window.setTimeout(CheckActive,1000); 
            return true; 
        } 
 
        usertimer++; 
         
        if (usertimer  > <%=(session.Timeout * 60) - 45 %>
        { 
        Logout() 
        return true; 
        } 
         
    timer1 = window.setTimeout(CheckActive,1000); 
    } 
 
 
</script> 
</telerik:RadCodeBlock> 
 
 
    </form> 
  </body> 
</html> 
 
 


Thanks in advance,
-Sharif

16 Answers, 1 is accepted

Sort by
0
SamJ
Top achievements
Rank 1
answered on 20 Jan 2009, 09:21 AM
HI,

Try changing your reset function as below:

function ResetTimer()   
{  
  UserActive = true;  
  currentTime = new Date()  
  if (Minutes != currentTime.getMinutes())  
  {  
     Minutes = currentTime.getMinutes()  
    //PROBLEM IS HERE 
     
//No matter how I declare this the method is not found 
// I've used both capital and lower case "a" in the method 
//tried document.getelementbyID 
// tried $find 
 
    var ajaxManager = $find("<%= RadAjaxManager1.ClientID %>");  
    ajaxManager.ajaxRequest('KeepAlive');  
  }  

Note how the ajax manager client object is accessed with the $find() method and the manager client ID is surrounded by quotes. and the "old" AjaxRequest() method is now called ajaxRequest().

Regards,
SamJ


0
Sharif
Top achievements
Rank 1
answered on 20 Jan 2009, 03:25 PM
Thanks for the Quick Reply Sam,

Unfortunately I'm still recieving an error when I try what you suggested.  Now, I get the following message instead: Microsoft JScript runtime error: 'null' is null or not an object

In this case, I see in debug mode that the variable ajaxManager is indeed evaluating to null which explains the error above.  when I was trying other methods the variable recieved the html span tag but not the real object I'm looking for I suspect.

Any other ideas?
Thanks again,
-Sharif
0
SamJ
Top achievements
Rank 1
answered on 21 Jan 2009, 05:28 AM
HI Sharif,

Try calling the ResetTimer() method on pageLoad instead on the body events and see if it works. Maybe you are trying to get the client object of the manager too early, when not all the page is loaded and client objects created.

function pageLoad(sender, eventArgs) 
    ResetTimer(); 

Tell me how it goes.


0
Miche B
Top achievements
Rank 1
answered on 17 Dec 2009, 07:20 AM
I am experiencing this same problem and have been trying to figure it out all day.  Is there a solution for using ajaxRequest()?  How do I get the ajaxRequest set up? 

No matter where I put this javascript on the page or even in a codeblock I either get
Microsoft JScript runtime error: Object doesn't support this property or method error or my ajaxManager object is null

<script language="javascript" type="text/javascript">  
       function rg_rebind() {  
            //var ajaxManager = <%=RadAjaxManager1.ClientID%>;  //failed  
            //var ajaxManager = $find("<%= RadAjaxManager1.ClientID %>"); //failed  
            //ajaxManager.ajaxRequest('Rebind');    //failed  
 
            <%= RadAjaxManager1.ClientID %>.ajaxRequest("<%= RadGrid1.UniqueID %>""Rebind");  
        }  
 
        window.onload = rg_rebind;  
</script> 

I have also triied putting the code below in the page load of the cs but the javascript still fails

 

 

 

if (RadAjaxManager1.IsAjaxRequest)  
{  
RadAjaxManager1.ResponseScripts.Add(string.Format("ajaxManager = window['{0}']", RadAjaxManager1.ClientID));  
}  
 
 

Why can't I execute the ajaxRequest() and why aren't the RadGrid or RadAjaxManager objects found?

Any help would be appreciated. 

Miche

0
Iana Tsolova
Telerik team
answered on 17 Dec 2009, 03:49 PM
Hello Miche,

Could you please specify which version of RadAjax you are using, is it RadAjax for ASP.NET or RadAjax for ASP.NET AJAX? 


Regards,
Iana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Miche B
Top achievements
Rank 1
answered on 17 Dec 2009, 04:41 PM
I am using RadControls for ASP.NET AJAX Q2 2009 NET35  - this was the latest available download we had. 

Thanks again,
Miche
0
Iana Tsolova
Telerik team
answered on 18 Dec 2009, 11:32 AM
Hello Miche,

In this case you should be able to invoke ajax request sing the ajaxRequest() client-side method of RadAjax as shown below:

function pageLoad()
{
    $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind");
}

In the RadAjaxManager declaration you should the following setting:

<telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
    <UpdatedControls>
        <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
    </UpdatedControls>
 </telerik:AjaxSetting>

Then handle the RadAjaxManager AjaxRequest serve event:

protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
{
    if (e.Argument == "Rebind")
    {
        RadGrid1.Rebind();
    }
}

For more information please review the listed online resources:
http://www.telerik.com/help/aspnet-ajax/ajxradajaxmanagerclientobject.html
http://www.telerik.com/help/aspnet-ajax/ajxaddajaxrequesttoclientevent.html

Regards,
Iana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Miche B
Top achievements
Rank 1
answered on 22 Dec 2009, 09:51 PM
Thanks Iana that seemed to work.  Now I have the opposite problem where I can't get out a loop.    As you suggested above,
   <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" > 
   </telerik:RadAjaxManager> 
      
    <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">  
        <updatedcontrols> 
                   <telerik:AjaxUpdatedControl ControlID="RadGrid1"  LoadingPanelID="RadAjaxLoadingPanel1"  /> 
                </updatedcontrols> 
    </telerik:AjaxSetting> 
      
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Vista" InitialDelayTime="0">  
        <asp:Image ID="Image1" runat="server" AlternateText="Loading..." ImageUrl="Vista.gif" /> 
    </telerik:RadAjaxLoadingPanel> 

and I used the pageload()
        function pageLoad()   
        {   
            $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind");   
        } 

But my code seems to be rebinding after it is done rebinding.  Does pageLoad() run every time the page is loaded?  Can I get it to run just once or is this a problem with a repeated AjaxManager call? 

I realize this is a new question so if I should repost as new, let me know.

Thank you
Miche
0
Iana Tsolova
Telerik team
answered on 23 Dec 2009, 07:24 AM
Hi Miche,

Indeed, the pageLoad event is executed after each postback/callback. So please excuse me for misleading you. The proper code is shown below. And thus the ajax request will be invoked only on initial load.

<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">   
<script type="text/javascript">   
function pageLoad(sender, eventArgs)   
{   
   if(!eventArgs.get_isPartialLoad())   
   {   
       $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind");   
   }   
}      
</script>   
</telerik:RadCodeBlock>


All the best,
Iana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Mark Galbreath
Top achievements
Rank 2
answered on 23 Dec 2009, 01:51 PM
Then why isn't $find() used in any of the documentation showing use of RadAjaxManager?  Don't you think that may have helped?

In any event, $find() is an implicit function and is not needed.

Mark
0
Mark Galbreath
Top achievements
Rank 2
answered on 23 Dec 2009, 02:11 PM
Any reason you can think of that the methods enumerated at http://www.telerik.com/help/aspnet-ajax/ajxradajaxmanagerclientobject.html are returning "undefined"?

Using .Net 3.5, 2009Q21028

Mark
0
Mark Galbreath
Top achievements
Rank 2
answered on 23 Dec 2009, 02:13 PM
Scratch that last post...the pages have been removed.

Mark
0
Mark Galbreath
Top achievements
Rank 2
answered on 23 Dec 2009, 02:15 PM
Then why isn't $find() used in any of the downloadable documentation showing use of RadAjaxManager?  Don't you think that may have helped?

In any event, $find() is an implicit function and is not needed.

Mark
0
Tsvetoslav
Telerik team
answered on 28 Dec 2009, 03:35 PM
Hello Mark,

$find() is a method of the Ajax framework that gives a reference to the client component related to a server control. Therefore, when documenting the client-side api of the RadAjaxManager there is no need to mention the $find() method. Could you clarify and give an example of what you meant by why isn't $find() used in any of the downloadable documentation showing use of RadAjaxManager?

Thanks.
Regards,
Tsvetoslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Mark Galbreath
Top achievements
Rank 2
answered on 28 Dec 2009, 05:03 PM
$find() is a method of the Ajax framework that gives a reference to the client component 
related to a server control. Therefore, when documenting the client-side api of the 
RadAjaxManager there is no need to mention the $find() method. Could you clarify and 
give an example of what you meant by why isn't $find() used in any of the downloadable 
documentation showing use of RadAjaxManager
?  
 
Thanks.  
Regards,  
Tsvetoslav  

Uh, that's what I just stated, Tsvetoslav.

As for my reference about $find() not being use in the downloadable documentation, (a) apparently Telerik doesn't permit us to download documentation anymore, but (b) in the copy of the RadControls for ASP.NET AJAX User Guide I d/l last July, Chapter 4, "Client-Side API," introduces $find(), but then never uses it in any examples, and (typical of Telerik documentation) does not tell the reader why it isn't being used.

Cheers!
Mark
0
Miche B
Top achievements
Rank 1
answered on 29 Dec 2009, 03:49 AM
Thanks Iana - I am out of the loop and on to other problems :) 

-Miche
Tags
Ajax
Asked by
Sharif
Top achievements
Rank 1
Answers by
SamJ
Top achievements
Rank 1
Sharif
Top achievements
Rank 1
Miche B
Top achievements
Rank 1
Iana Tsolova
Telerik team
Mark Galbreath
Top achievements
Rank 2
Tsvetoslav
Telerik team
Share this question
or