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

RadAjaxManager.ajaxRequest from a rad window

5 Answers 248 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Jeff Wowk
Top achievements
Rank 1
Jeff Wowk asked on 11 Feb 2014, 07:42 PM
In a radwindow I'm trying to run server side code through the RadAjaxManager.ajaxRequest on docuemnt.Ready(). I get he following javascriopt error 0x800a138f - JavaScript runtime error: Unable to get property 'ajaxRequest' of undefined or null reference.  I assume the $find("RadAjaxManager1").ajaxRequest("Rebind") line isn't finding the RadAjaxManager Control.  Can I not call the ajaxRequest in document.ready()?  Is it too early?
 The control is named properly from what I can tell.

Code is below

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="DListFullTel_Update_Mult.aspx.vb" Inherits="DListFullTel_Update_Mult" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>

    <asp:PlaceHolder ID="PlaceHolder1" runat="server">

<script src="Scripts/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" language="javascript">
        $(document).ready(function () {


            
            
            $("#rblChoice_0").click(function (e) {
                disableSubmit()
            });
            $("#rblChoice_1").click(function (e) {
                disableSubmit()
            });
            $("#rblChoice_2").click(function (e) {
                disableSubmit()
            });
            $("#taComments").keyup(function () {
                disableSubmit()
            });
            $("#taComments").mouseleave(function () {
                disableSubmit()
            });

            $("#hdDataIDs").val(GetRadWindow().BrowserWindow.document.getElementById("txtInput").value) ;

            GetPageValues()

        });
        function disableSubmit() {
            if (($.trim($("#taComments").val()) == "") && ($("#rblChoice input:radio:checked").val() == 2)) {
                $("#btnSubmit").attr("disabled", "disabled")
            }
            else {
                $("#btnSubmit").removeAttr("disabled", "disabled")
            }
        }
        function CloseAndRebind(args) {
            GetRadWindow().BrowserWindow.refreshGrid(args);
            GetRadWindow().close();
        }
        function GetRadWindow() {
            var oWindow = null;
            if (window.radWindow) oWindow = window.radWindow; //Will work in Moz in all cases, including clasic dialog                  
            else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; //IE (and Moz as well)                  
            return oWindow;
        }
        function CancelEdit() {
            GetRadWindow().close();
        }
        function GetPageValues(arg) {

            $find("<%= RadAjaxManager1.ClientID%>").ajaxRequest("Rebind");

        }
    </script>
    </asp:PlaceHolder>


    
    
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <div id="divReturn">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server"></telerik:RadSkinManager>
    <telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" />
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest1">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="hdDataIDs" LoadingPanelID="RadAjaxLoadingPanel1"></telerik:AjaxUpdatedControl>
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="hdDataIDs">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="hdDataIDs" LoadingPanelID="RadAjaxLoadingPanel1"></telerik:AjaxUpdatedControl>
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Default"></telerik:RadAjaxLoadingPanel>
        <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" HorizontalAlign="NotSet" LoadingPanelID="RadAjaxLoadingPanel1">
<asp:HiddenField ID="hdDataIDs" runat="server" ClientIDMode="Static" Value="not yet" />
<table style="width: 200px; border: 0px;" cellpadding="3" cellspacing="0">
            
            <tr>
                <td colspan="2" style="padding-left: 15px;">
                    <div id="brands">
                        <asp:RadioButtonList ID="rblChoice" runat="server" ClientIDMode="Predictable" 
                            RepeatDirection="Horizontal">
                            <asp:ListItem Value="0">Pending</asp:ListItem>
                            <asp:ListItem Selected="True" Value="1">Don&#39;t Keep</asp:ListItem>
                            <asp:ListItem Value="2">Keep</asp:ListItem>
                        </asp:RadioButtonList>
                    </div>
                </td>
            </tr>
            <tr>
                <td style="vertical-align: top; padding-left: 20px">
                    Comments:
                </td>
                <td>
                    <textarea id="taComments" name="taComments" cols="25" rows="5"></textarea>
                </td>
            </tr>
            <tr>
                <td>
                    &nbsp;
                </td>
                <td>
                    &nbsp;
                </td>
            </tr>
            <tr>
                <td colspan="2" style="padding-left: 15px;">
                    <span style="font-weight: bold;">Apply to:</span>&nbsp;<asp:Label ID="lbldialogParentName" runat="server" Text="Label"></asp:Label>
                </td>
            </tr>
            <tr>
                <td colspan="2" style="text-align: center;">
                    <input id="btnSubmit" type="button" value="Submit" disabled="disabled" />&nbsp;&nbsp;
                    <input id="btnClose2" type="button" value="Cancel" />
                    <asp:HiddenField ID="hdlbldialogParentID" runat="server" ClientIDMode="Static" />
                    <asp:HiddenField ID="hdlbldialogDispNodeID" runat="server" ClientIDMode="Static" />
                    <asp:HiddenField ID="hdlbldialogUserID" runat="server" ClientIDMode="Static" />
                </td>
            </tr>
        </table>
        </telerik:RadAjaxPanel>
   
    </div>
    </div>
    </form>
</body>
</html>





5 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 12 Feb 2014, 09:02 AM
Hi Jeff Wowk,

Being an ASP.NET Ajax control RadAjaxManager is initialized later than the document.ready event. In this case, I would suggest that move your JavaScript to the pageLoad event.

Thanks,
Princy.
0
Jeff Wowk
Top achievements
Rank 1
answered on 14 Feb 2014, 04:47 PM
Morning Princy

The document.load() event also seems to be too early in the life cycle.  And the Server Side Page Load event won't work either.  I'm trying to sent a lot info to my radwindow.  In this case a string of IDs.  This string can grow to be too big for the querystring in IE.  I know I can grab the string I need using javascript in the radwindow reaching back to the parent window, but I can't do that server side.

I also can't:
Server Page Load
   ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "GetPageValues();", True)


Javascript GetPageValues()
\\Set the values
\\Return to Server Page Load and use the values.  Values aren't there for some reason
OR
\\Call another server side function.  It just breaks things.

Thanks
Jeff.




0
Viktor Tachev
Telerik team
answered on 19 Feb 2014, 12:38 PM
Hi Jeff,

I am not completely sure what scenario you are trying to implement. Would you elaborate more on what are your requirements and what should be the expected result? It seems that you are firing an Ajax request on document.ready(). Why do you need to call ajaxRequest() on that event? Having better understanding of your scenario would allow us to provide proper suggestions on how it could be achieved.

On a side note in the code you provided it seems that some controls are Ajax-ified with RadAjaxManager and RadAjaxPanel at the same time. It is highly recommended to avoid this as stated in this article.

Additionally the ClientIDMode is set to static for some of the controls. This mode should not be used with our controls, especially when they are Ajax-ified, as it could lead to unexpected results. It is recommended to use ClientIDMode set to AutoID. More information on the subject is available in this troubleshooting article.

Moreover I would suggest taking a look at this article related to using RadWindow with Ajax.


Regards,
Viktor Tachev
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 UI for ASP.NET AJAX, subscribe to the blog feed now.
0
Jeff Wowk
Top achievements
Rank 1
answered on 07 Mar 2014, 06:00 PM
Hey.

On my parent page I have a radgrid that contains a list of records.  I am allowing users to select multiple records(0-500).  Click an update button, radwindow opens, user can select a few changes and update all of the selected records with the changes.  Then refresh the radgrid on the parent page.  My problem is I need to send a list of IDs to the radwindow.  On the surface I can only do that through the querystring.  A comma delimited string of IDs can grow be too long for a url in IE.  I know I can reach back from the radwindow to the parent using javascrpt and grab the values from a hidden field, but I need to use the IDs in the code behind Page Load event of the radwindow.

Right now my work around is to put the string of IDs into a session variable before opening the radwindow, open the radwindow, use the ID and clear the session variable.

I'd like to know if there is a better way to send large amounts of data to a radwindow

0
Viktor Tachev
Telerik team
answered on 12 Mar 2014, 01:29 PM
Hi Jeff,

I do not see anything wrong with the way you are passing the IDs in a Session variable to the RadWindow. You could use that approach if it works for you.

On a side note, if you would like to make multiple changes to the data in RadGrid and update the values with a single request you might consider using Batch editing mode for the RadGrid. It provides such functionality out of the box.


Regards,
Viktor Tachev
Telerik
 

DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

 
Tags
Ajax
Asked by
Jeff Wowk
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Jeff Wowk
Top achievements
Rank 1
Viktor Tachev
Telerik team
Share this question
or