AjaxLoadingPanel and Javascript

4 posts, 1 answers
  1. John
    John avatar
    8 posts
    Member since:
    Feb 2012

    Posted 07 Jun 2013 Link to this post

    Hi,

    I have used RadAjaxLoadingPanel in my page as following.
    ------------------------------------------------------------------------------
    <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">     <script type="text/javascript">          function requestStart(sender, args) {             if (args.get_eventTarget().indexOf("ExportToExcelButton") >= 0) {                 args.set_enableAjax(false);             }         }         function ValidateData() {                          return true;         }     </script>          <table style="width100%;">                 <tr>             <td class="TDInfoLabel" style="width20%;"></td>             <td class="TDInfoValue">                 <asp:Button ID="btnSearch" runat="server" Text="Search" CssClass="button" OnClientClick="return ValidateData();" />             </td>         </tr>     </table>     <br />     <div style="overflowautoheight100%font-size12px;">                 <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">         </telerik:RadAjaxLoadingPanel>         <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" LoadingPanelID="RadAjaxLoadingPanel1"             ClientEvents-OnRequestStart="requestStart">         <telerik:RadGrid ID="rgvUserData" runat="server" Skin="Hay" AutoGenerateColumns="False" CellSpacing="0" GridLines="None"             PageSize="50" AllowPaging="True" PagerStyle-Mode="NextPrevAndNumeric">             <ClientSettings AllowGroupExpandCollapse="true" EnableRowHoverStyle="true" Selecting-AllowRowSelect="true">                 <Selecting AllowRowSelect="True"></Selecting>             </ClientSettings>             <MasterTableView CommandItemDisplay="Top" GroupLoadMode="Client" AllowMultiColumnSorting="false" GroupHeaderItemStyle-ForeColor="Black"                 PageSize="50" UseAllDataFields="False">                 <CommandItemSettings ExportToPdfText="Export to PDF" ShowExportToExcelButton="true" ShowAddNewRecordButton="false"></CommandItemSettings>                 <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column"></RowIndicatorColumn>                 <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column"></ExpandCollapseColumn>                 <EditFormSettings>                     <EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>                 </EditFormSettings>                 <GroupHeaderItemStyle ForeColor="Black"></GroupHeaderItemStyle>             </MasterTableView>             <ExportSettings FileName="ExportedData" IgnorePaging="True" OpenInNewWindow="False">                 <Excel Format="Html"></Excel>             </ExportSettings>             <HeaderStyle ForeColor="White" />             <FilterMenu EnableImageSprites="False"></FilterMenu>         </telerik:RadGrid>         </telerik:RadAjaxPanel>     </div>     <br /> </asp:Content>

    ------------------------------------------------------------------------------
    Now If I try to access any control in script section by following way
    var btn = document.getElementById("<%= btnSearch.ClientID%>"); 
    Or
    var btn = $find("<%= btnSearch.ClientID%>"); 

    then I am getting following errors when I try to run the page.
    Crome: Error : The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>). 

    IE: 0x800a138f - JavaScript runtime error: Unable to get property 'notifyScriptLoaded' of undefined or null reference.

    If I delete the lines accessing the controls from JavaScript section then it runs fine.

    Regards,
    John

  2. Answer
    msigman
    msigman avatar
    141 posts
    Member since:
    Apr 2008

    Posted 10 Jun 2013 Link to this post

    Hello,

    You can resolve this by wrapping any lines that contains the code blocks ("<% %>") in a RadCodeBlock control, like this:
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
    <script type="text/javascript">
        var btn = document.getElementById("<%= btnSearch.ClientID%>");
    </script>
    </
    telerik:RadCodeBlock>
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. John
    John avatar
    8 posts
    Member since:
    Feb 2012

    Posted 11 Jun 2013 Link to this post

    Hi msigman,

        It worked.... Thank you very much.

    Regards,
    John.
  5. msigman
    msigman avatar
    141 posts
    Member since:
    Apr 2008

    Posted 11 Jun 2013 Link to this post

    John,

    Glad to hear it!  Please mark as the accepted answer so future visitors can find it.

    Thanks,
    Matt
Back to Top