$find() returns null in response script from ajaxmanager

9 posts, 0 answers
  1. Fred Wesson
    Fred Wesson avatar
    15 posts
    Member since:
    May 2010

    Posted 20 May 2010 Link to this post

    I am trying to display a RadWindow after an ajaxrequest using the ajaxmanagers responsescripts.  It works fine if the ajax request originated from an ajaxpanel, but if the request originates from the ajaxmanager (RadAjaxManager.ajaxRequest('parm')), the $find() function always returns null.

    Here is the code behind response script.
    RadAjaxManager.ResponseScripts.Add(setTimeout(function(){var _window = $find('" + RadWindow.ClientID + "'); _window.show();}, 250)); 

    Am I missing something?
  2. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 21 May 2010 Link to this post

    Hi Fred,

    Please try using the following:

    JS:
    <script type="text/javascript">
        function OpenWindow(sender, args) {
      
           var oWnd = $find("<%= RadWindow1.ClientID %>");
            oWnd.show();
        }
      
    </script>

    C#:

    protected void Button1_Click(object sender, EventArgs e)
       {
            
          RadAjaxManager1.ResponseScripts.Add("OpenWindow");
       }



    Kind regards,
    Maria Ilieva
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Fred Wesson
    Fred Wesson avatar
    15 posts
    Member since:
    May 2010

    Posted 21 May 2010 Link to this post

    Same result...I think it's a problem with the ajaxmanager since it works fine if the ajax request originates somewhere other than the ajax manager.
  5. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 21 May 2010 Link to this post

    Hello Fred,

    I tested this scenario locally however was not able to replicate the described error. Could you please open a regular support ticket and send us small runnable application so we could test it locally and further research on the problem.


    All the best,
    Maria Ilieva
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  6. Fred Wesson
    Fred Wesson avatar
    15 posts
    Member since:
    May 2010

    Posted 21 May 2010 Link to this post

    Thank you...I've opened ticket# 312184
  7. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 24 Jun 2010 Link to this post

    Fred,

    FWIW, I've just encountered a similar error.

    The solution, I found, was to make sure that your calling control updates the window control in your ajax settings.

    In my case, I have a button that is supposed to open a window that uses a ContentTemplate, which means it can't be in a RadWindowManager.

    I was just using this ...
        protected void btnBeginLogin_Click(object sender, EventArgs e) 
        { 
            RadAjaxManager1.ResponseScripts.Add("openWindow();"); 
        } 

    to open the window, but was not getting anywhere. The script function, incidentally, looks like this ...
                function openWindow() { 
                    var wnd = $find("<%= RadWindow1.ClientID %>"); 
                    wnd.show(); 
                } 

    All I needed to do was add a new set of AjaxSettings to my AjaxManager ...
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"
            <AjaxSettings> 
                <telerik:AjaxSetting AjaxControlID="btnBeginLogin"
                    <UpdatedControls> 
                        <telerik:AjaxUpdatedControl ControlID="RadWindow1" /> 
                    </UpdatedControls> 
                </telerik:AjaxSetting> 
            </AjaxSettings> 
        </telerik:RadAjaxManager> 

    I'm guessing here, but I wonder if replacing "btnBeginLogin" in the above with the name of your AjaxManager control would fix your problem.

    -- 
    Stuart. If this answers your question, please don;t forget to use the "Mark as answer" link.


  8. Matthew
    Matthew avatar
    51 posts
    Member since:
    Oct 2012

    Posted 05 Aug 2013 Link to this post

    Stuart: According to this page, it's best to avoid ajaxifying a RadWindow directly.

    Was this problem resolved? I've encountered a similar problem.
  9. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 08 Aug 2013 Link to this post

    Hi Matthew,

    The mentioned rule is valid for cases when you are using RadWindow control with Content Template in it. In this case instead of ajaxifying the whole RadWindow you should ajaxify the controls in the Content Template.
    Could you please elaborate what the exact issue you are facing is so that we could further assist?

    Regards,
    Maria Ilieva
    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.
  10. Matthew
    Matthew avatar
    51 posts
    Member since:
    Oct 2012

    Posted 08 Aug 2013 Link to this post

    In my scenario I use a RadListView to dynamically create a RadWindow (using ContentTemplate) for some records in my database. I couldn't do the typical $find('<% RadWindowX.ClientID %>') because they're inside the RadListView template. I couldn't use static IDs on the RadWindows because that breaks them. I set each RadWindow's ID in the code-behind in order to get uniqueness--I had an issue where after a callback/postback the RadWindows would all be ctrl100 or whatever that default is. In the end I resolved the issue by modifying this KB article to find the RadWindow using the ID I knew I was going to give it.

    function getRadWindow(id) {
        if(!Telerik.Web.UI.RadWindow) return null;
        var RadWindows = $telerik.radControls.filter(function (elem) {
            return elem instanceof Telerik.Web.UI.RadWindow;
        });
        var rw = RadWindows.filter(function (elem) {
            return elem.get_name() == id;
        });
        if (rw.length != 1) {
            console.log("Windows: " + rw.map(function (elem) { elem.get_name() + ' '; }));
            return null;
        }
        else return rw[0];
    }

    When I started using this I figured out the RadWindow IDs were getting reset, so that was probably my issue. I must've set the IDs on the initial request, but neglected to set it again on the callbacks/postbacks.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017