RADAjax Manager does not load JS files in dynamically loaded user control

66 posts, 0 answers
  1. Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 20 Feb 2009 Link to this post

    Hello Albert,

    I have attached a small application demonstrating similar scenario. Can you please take a look maybe I'm missing something obvious?

    Greetings,
    Rosen
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  2. Albert Shenker
    Albert Shenker avatar
    550 posts
    Member since:
    Mar 2004

    Posted 23 Feb 2009 Link to this post

    I am not a C# programmer, but I think I was able to figure out the code which was attached. I don't know if it works since it isn't a project, but I assume you tested it. Anyways, other than the fact that you are ajaxifying a placeholder control (something I have thought you could not do with Telerik Controls), it seems pretty straightforward. Unfortunately, I am not implementing such a straight forward example. Mine is more like your "Load-On-Demand" tabs demo. Interestingly, the Load On Demand Tabs example does not use the "LastLoadedControl" construct you have in the attached code Page_Load event. When I first implemented load on demand tabs, I was a little surprised about the ommision, but the demo works, so I assume it is not necessary.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Albert Shenker
    Albert Shenker avatar
    550 posts
    Member since:
    Mar 2004

    Posted 02 Mar 2009 Link to this post

    Any update on this?
  5. Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 04 Mar 2009 Link to this post

    Hello Albert,

    Can you please send us (attached to a formal ticket)  a small sample project in which the behavior in question can be reproduce? Thus we will be able to gather more details about the your exact scenario and provide you with detailed answer.

    Sincerely yours,
    Rosen
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  6. Albert Shenker
    Albert Shenker avatar
    550 posts
    Member since:
    Mar 2004

    Posted 11 Mar 2009 Link to this post

    Well, after going through a support ticket, I have found the following...If, you are loading usercontrols via ajax (such as in the Telerik load-on-demand pageview example), then there are some scenarios under which this will not work..

    If you have any javascript script blocks within the user control....

    You must either, set the ajaxmanager RestoreOriginalRenderDelegate property to true, or your page must inherit from the Telerik RadJaxPage base class instead of System.Web.UI.Page.

    Doing the first will in all likelihood prevent your app from working in many 3rd party hosting environments as they are being run in medium trust.

    Doing the second is certainly straightforward, however, in many cases a developer does not have a choice of which page base class to inherit from, as is the case in my scenario.

    So for me, it would appear that the use of Telerik Ajax to load User controls has some serious limitations. According to the support tech, these are limitations of MS Ajax, and there is no way around them except the two methods I mentioned.
  7. Josh
    Josh avatar
    42 posts
    Member since:
    May 2009

    Posted 15 Sep 2009 Link to this post

    Dear Telerik,

    Is the above the last word on this problem?  I am trying to create a RadGrid using a user control as the insert/edit form.  I've found that on adding a new row to the grid the user control's javascript is not recognized.  That is, I get a " 'Null' is not null or an object" error message on the OnClientClick event. 

    I don't have any problem with editing strangely enough.  If information exists then the form works without error.

    I've also tried to put the usercontrol's Javascript and include it in a RadScriptBlock, but I receive an error that the .js file cannot be found. 

    Any news on this? Solutions?

    Sincerely,
    Josh
  8. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 16 Sep 2009 Link to this post

    Hi Josh,

    Can you send us small example (via support ticket) where we can reproduce and debug this problem?

    All the best,
    Vlad
    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.
  9. Josh
    Josh avatar
    42 posts
    Member since:
    May 2009

    Posted 16 Sep 2009 Link to this post

    Dear Vlad,

    I have solved my problem.  Because the radgrid dynamically loads the usercontrol the clientIDs do not yet exist.  Therefore, it is necessary to pass the clientIDs from the RadGrid1_ItemDataBound event after the usercontrol has been loaded to the Javascript via something like the below code:

     

     

    script.Append("clientCalendar = '" + calendarClientID + "';");   
    RadAjaxManager.GetCurrent(Page).ResponseScripts.Add(script.ToString());   
     

     

    The clientCalendar is a variable in the Javascript that gets populated with the ClientID value from the C# code. 
    My biggest issue was the fact that the Item could be obtained from Insert, but not edit, in the ItemCommand Event.
    Like so:

    if (e.CommandName == RadGrid.InitInsertCommandName)   
    {  
    other code...   
    GridEditableItem insertedItem = e.Item.OwnerTableView.GetInsertItem();   
    // Get the insert/edit form's user control    
    UserControl uc = insertedItem.FindControl(GridEditFormItem.EditFormUserControlID) as UserControl;   


    If you attempt to do something like the above except with the RadGrid.EditCommandName it fails.  The ItemDataBound event must be used to obtain the user control during the Edit event.

    Josh

     

     

  10. Zeke Sheppard
    Zeke Sheppard avatar
    32 posts
    Member since:
    Oct 2009

    Posted 18 Feb 2010 Link to this post

    Albert, 
    Setting the RadAjaxManager RestoreOriginalRenderDelegate to True on the container page did not resolve this issue. Client side function still not found on the .ascx and prevented LoadControl from succeeding.

    Are you doing something different to allow this to work?
  11. Albert Shenker
    Albert Shenker avatar
    550 posts
    Member since:
    Mar 2004

    Posted 18 Feb 2010 Link to this post

    Zeke, I have given up loading user controls using AJAX given the limitations described in this thread. What you are doing sounds like it should work, though not in 3rd party hosting environments. If it isn't working, I would sugeest you submit a support ticket with Telerik.
  12. Zeke Sheppard
    Zeke Sheppard avatar
    32 posts
    Member since:
    Oct 2009

    Posted 18 Feb 2010 Link to this post

    Albert, thanks for the prompt response.

    This seemed like a promising resolution, since I've got control of the environment, but to no avail. Telerik to this point, has been unable to provide a workable solution despite repeated inquiries.

    Thanks again for your response.

     

  13. Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 19 Feb 2010 Link to this post

    Hi Zeke,

    Can you please provide more detailed information on what your scenario is? Please verify that your are using RadScriptBlock control around the scripts you need to be loaded. It will be appreciated if you can send us (attached to a formal ticket) a small runnable sample.
    Also did you look at the attached sample in this thread which demonstrates similar functionality.

    Best wishes,
    Rosen
    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.
  14. Zeke Sheppard
    Zeke Sheppard avatar
    32 posts
    Member since:
    Oct 2009

    Posted 19 Feb 2010 Link to this post

    Your site has literally dozens of non working samples (pick any one), including this thread, yet no working solution from Telerik. Your group has never given any working solution to this issue. Please provide a solution to the original issue listed on this thread. This has not happened to date.

    As evidenced in this thread, even experienced Telerik users have given up on this technique, due to the inability to determine a workable solution. This appears to be an issue known to your group for at least two years.

     

     

     

  15. Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 19 Feb 2010 Link to this post

    Zeke,

    I have attached a fully runnable sample which demonstrates how to accomplish the scenario from the first post in this thread. Please let me know if I'm missing something obvious.

    All the best,
    Rosen
    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.
  16. Albert Shenker
    Albert Shenker avatar
    550 posts
    Member since:
    Mar 2004

    Posted 19 Feb 2010 Link to this post

    In your smaple project, is there a particular reason you have an update panel in the declaration? Also, this example doesn't make use of the LastLoadedControlName convention that Telerik typically employs in their dynamic user controls examples. Is this no longer necessary for some reason, or is it only unecessary in Ajax scenarios?
  17. Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 19 Feb 2010 Link to this post

    Albert ,

    As you can see the UpdatePanel is commented out and it is just a leftover from some testing not related to the sample. As to the rest of the code and naming etc. it is directly taken from the first post in this thread.
    Note that the example is not how to load/reload usercontrols but to demonstrate the script resolving.

    Sincerely yours,
    Rosen
    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.
  18. Albert Shenker
    Albert Shenker avatar
    550 posts
    Member since:
    Mar 2004

    Posted 19 Feb 2010 Link to this post

    Just so I am not confused, what originally brought me to this thread was that I was trying to implement your dynamically loaded user controls examples using ajax, and was having issues when the user controls contained javascript. To my knowledge, the only way Telerik has found around these issues was setting RestoreOriginalRenderDelegate to true, or inheriting the page from a Telerik Page Base class. The first option is problematic because it won't work in most 3rd party hosted environments. The second is problematic because, at least in my case, I don't have an option as to what base class my pages inherit from.

    So, that is why I abandoned the idea of dynamically loading user controls using AJAX. Just so I'm clear, regardles of whether the previously attached project solves the original issue in this thread, Telerik hasn't yet come up with a better way (other that the two options I mentioned) of circumventing this limitaiton in AJAX. Is this correct?
  19. Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 22 Feb 2010 Link to this post

    Hello Albert,

    If I can recall correctly you have issues with medium trust environments and as you know (and stated in the docs) in order  RadAjax to work as expected in such environments RadAjaxPage need to be used due to some limitations in ASP.NET Page's architecture in extensibility aspect. In full trust  environments (as the one demonstrated in the sample) there is not need for such extra step and scripts should be evaluated in the demonstrated manner.

    However with Q1 2010 version of RadControls for ASP.NET AJAX we will introduce an interface which can be implemented in case you are using a base page which cannot be modified. By using this interface you will be able to use the RadAjax in medium trust environments by providing the RadAjaxPage's functionality by your own, thus without need to directly inherit from RadAjaxPage.

    Kind regards,
    Rosen
    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.
  20. Albert Shenker
    Albert Shenker avatar
    550 posts
    Member since:
    Mar 2004

    Posted 22 Feb 2010 Link to this post

    Thanks. That's exactly the sort of solution I was looking for. I look forward to the next release.
  21. Deepak Saboji
    Deepak Saboji avatar
    14 posts
    Member since:
    Feb 2010

    Posted 24 Aug 2010 Link to this post

    Hi,

    Has this problem been fixed in the latest version? If it is, please let us know the version details.

    Thanks,
    Deepak Saboji.

  22. Austin
    Austin avatar
    13 posts
    Member since:
    Apr 2009

    Posted 22 Sep 2010 Link to this post

    It seems like a long enough time frame has gone by for the last question asked, which is 'any update yet?'  So I'm going to second the question.  Any update yet??
  23. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 25 Sep 2010 Link to this post

    Hello Austin,

    Normally, when you have javascript block in your dynamically loaded control, for that javascript to be evaluated properly, you need to wrap it in a RadScriptBlock.
    A possible reason for this solution not to work is if you have any invalid ajax settings. So you should either refactor your ajax settings or register the scripts manually calling the ScriptManager.RegisterStartupScript() static method.

    All the best,
    Iana
    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
  24. Austin
    Austin avatar
    13 posts
    Member since:
    Apr 2009

    Posted 29 Dec 2010 Link to this post

    Actually, I was asking for an update to the post given by Rosen on Feb 22, 2010... is there any update on this functionality:

    Rosen posted:
    "However with Q1 2010 version of RadControls for ASP.NET AJAX we will introduce an interface which can be implemented in case you are using a base page which cannot be modified. By using this interface you will be able to use the RadAjax in medium trust environments by providing the RadAjaxPage's functionality by your own, thus without need to directly inherit from RadAjaxPage."

    Thanks,
  25. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 30 Dec 2010 Link to this post

    Hello Austin,

    The mentioned interface was implemented just as my colelague stated. You can find more information on it here.

    Regards,
    Iana
    the Telerik team
    Browse the vast support resources we have to jump start 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.
  26. Austin
    Austin avatar
    13 posts
    Member since:
    Apr 2009

    Posted 30 Dec 2010 Link to this post

    Thanks, that is what I was looking for!  We implemented a different approach to get around this issue due to time requirements, but if we run into this again, or ever rework that area, then I will give this a try.
  27. Kyaw
    Kyaw avatar
    10 posts
    Member since:
    Apr 2012

    Posted 22 May 2012 Link to this post

    Hi Telerik Team,

    I also can't fix this issue.
    Master page i referenced some javascript files, css and inline script. And added the RadCodeBlock, RadAjaxManager and RadAjaxLoadingPanel. After post back reference javascript, css and inline script are not working.

    <head>
    <script type="text/javascript" src="../../Scripts/jquery-1.6.1.min.js"></script>
     
        <script type="text/javascript" src="../../Scripts/jquery_YPbanner.js"></script>
     
        <script type="text/javascript">
     
            //TEXT RESIZE
            function getCookie(c_name) {
                if (document.cookie.length > 0) {
                    c_start = document.cookie.indexOf(c_name + "=");
                    if (c_start != -1) {
                        c_start = c_start + c_name.length + 1;
                        c_end = document.cookie.indexOf(";", c_start);
                        if (c_end == -1) c_end = document.cookie.length;
                        return unescape(document.cookie.substring(c_start, c_end));
                    }
                }
                return "";
            }
     
            function setCookie(c_name, value, expiredays) {
                var exdate = new Date();
                exdate.setDate(exdate.getDate() + expiredays);
                document.cookie = c_name + "=" + escape(value) +
                    ((expiredays == null) ? "" : ";expires=" + exdate.toGMTString());
            }
     
            var sitefunctions = {
                textresize: function() {
                    // show text resizing links
                    var $cookie_name = "PAGCFontSize";
                    var originalFontSize = $("body").css("font-size");
                    // if exists load saved value, otherwise store it
                    if (getCookie($cookie_name)) {
                        var $getSize = getCookie($cookie_name);
                        $("body").css({ fontSize: $getSize + ($getSize.indexOf("px") != -1 ? "" : "px") }); // IE fix for double "pxpx" error
                        if ($getSize.indexOf(14) != -1) { $(".gc_resizeBig").addClass("gc_resizeActive"); }
                        if ($getSize.indexOf(12) != -1) { $(".gc_resizeNormal").addClass("gc_resizeActive"); }
                        if ($getSize.indexOf(10) != -1) { $(".gc_resizeSmall").addClass("gc_resizeActive"); }
                    } else {
                        setCookie($cookie_name, originalFontSize);
                    }
                    // reset
                    $(".gc_resizeNormal").bind("click", function() {
                        $("body").css("font-size", 12);
                        setCookie($cookie_name, 12);
                        $(".gc_resizeActive").removeClass("gc_resizeActive");
                        $(this).addClass("gc_resizeActive");
                        return false;
                    });
                    // text small
                    $(".gc_resizeSmall").click(function() {
                        $("body").css("font-size", 10);
                        setCookie($cookie_name, 10);
                        $(".gc_resizeActive").removeClass("gc_resizeActive");
                        $(this).addClass("gc_resizeActive");
                        return false;
                    });
                    $(".gc_resizeBig").click(function() {
                        $("body").css("font-size", 14);
                        setCookie($cookie_name, 14);
                        $(".gc_resizeActive").removeClass("gc_resizeActive");
                        $(this).addClass("gc_resizeActive");
                        return false;
                    });
     
                }
            };
     
            $(document).ready(function() {
                $(".gc_homeTabsContents > div").hide();
                $(".gc_homeTabsContents > div:first").show();
                $(".gc_homeTabsItems ul li").click(function() {
                    if ($(this).attr("class") != "active") {
                        //SWITCH TAB STYLE
                        $(this).siblings().removeClass("active");
                        $(this).addClass("active");
     
                        //SWITCH CONTENT
                        var thisnum = $("a", this).attr("href");
                        $(".gc_homeTabsContents > div").hide();
                        $(".gc_homeTabsContents").find(thisnum).show();
                    }
                })
     
                //BANNER
                $('.BannerHolder').BannerRotator({
                    delay: 5000,
                    speed: 1000,
                    controlPOS: 'BR',
                    arrow: false,
                    startNum: 0
     
                });
                //============ TEXT RESIZE
                sitefunctions.textresize();
            });
        </script>
     
        <!-- <link href="../_Survey/NSurveyAdmin/CSS/nsurveyadmin.css" type="text/css" rel="stylesheet" /> -->
        <link href="../App_Themes/infolab/basic.css" type="text/css" rel="stylesheet" />
        <link href="../App_Themes/infolab/CustomTelerik.css" type="text/css" rel="stylesheet" />
    </head>
    <body>
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">
     
            function RequestStart(sender, args) {
                // the following Javascript code takes care of expanding the RadAjaxLoadingPanel
                // to the full height of the page, if it is more than the browser window viewport
     
                var loadingPanel = $get("<%= RadAjaxLoadingPanel1.ClientID %>");
                var pageHeight = document.documentElement.scrollHeight;
                var viewportHeight = document.documentElement.clientHeight;
     
                if (pageHeight > viewportHeight) {
                    loadingPanel.style.height = pageHeight + "px";
                }
     
                var pageWidth = document.documentElement.scrollWidth;
                var viewportWidth = document.documentElement.clientWidth;
     
                if (pageWidth > viewportWidth) {
                    loadingPanel.style.width = pageWidth + "px";
                }
     
                // the following Javascript code takes care of centering the RadAjaxLoadingPanel
                // background image, taking into consideration the scroll offset of the page content
     
                if ($telerik.isSafari) {
                    var scrollTopOffset = document.body.scrollTop;
                    var scrollLeftOffset = document.body.scrollLeft;
                }
                else {
                    var scrollTopOffset = document.documentElement.scrollTop;
                    var scrollLeftOffset = document.documentElement.scrollLeft;
                }
     
                var loadingImageWidth = 55;
                var loadingImageHeight = 55;
     
                loadingPanel.style.backgroundPosition = (parseInt(scrollLeftOffset) + parseInt(viewportWidth / 2) - parseInt(loadingImageWidth / 2)) + "px " + (parseInt(scrollTopOffset) + parseInt(viewportHeight / 2) - parseInt(loadingImageHeight / 2)) + "px";
            }
     
        </script>
        </telerik:RadCodeBlock>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel1">
            <ClientEvents OnRequestStart="RequestStart" />
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="pnl_Loading">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="pnl_Loading" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
     
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" IsSticky="true" CssClass="ModalPanel" Transparency="50" />
        <asp:Panel ID ="pnl_Loading" runat ="server">
    </asp:Panel>
    </body>

  28. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 23 May 2012 Link to this post

    Hi, Kyaw

    Try setting the EnablePageHeadUpdate property of the RadAjaxManager to false and see if it works.
    You can also replace the RadCodeBlock with RadScriptBlock and let me know if it makes any difference. Or at leaset wrap the scripts in the <head> tag with RadScriptBlock.

    All the best,
    Iana Tsolova
    the Telerik team
    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 their blog feed now.
  29. Kyaw
    Kyaw avatar
    10 posts
    Member since:
    Apr 2012

    Posted 23 May 2012 Link to this post

    Hi,

    After I changed EnablePageHeadUpdate property of the RadAjaxManager to false, the javascript is working fine.

    One more question, now i can't open RadAjaxManager1.ResponseScripts.Add(@"radalert('Class has been updated.', 300, 110,'Class Management');"); in my user control.

    Is there any way to call this kind of function.

    Thanks.
  30. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 25 May 2012 Link to this post

    Hi,

    Try registering the scripts through the ScriptManage instead:
    ScriptManager.RegisterStartupScripts(Page, typeof(Page), "script", radalert('Class has been updated.', 300, 110,'Class Management');", true);

    Greetings,
    Iana Tsolova
    the Telerik team
    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 their blog feed now.
  31. Kyaw
    Kyaw avatar
    10 posts
    Member since:
    Apr 2012

    Posted 28 May 2012 Link to this post

    Hi,

    I still have a problem , i put RadAjaxManager, Loading Panel and RadAjaxPanel in master page.
    Normal functions look fine.
    But for RadUpload control not working. If generated excel file, got issue like that "Server cannot set content type after HTTP headers have been sent.". 

    So many problems.


    Thanks.,
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017