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

AjaxLoadingPanel and Javascript

3 Answers 89 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 07 Jun 2013, 03:22 PM
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

3 Answers, 1 is accepted

Sort by
0
Accepted
msigman
Top achievements
Rank 2
answered on 10 Jun 2013, 06:20 PM
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>
0
John
Top achievements
Rank 1
answered on 11 Jun 2013, 08:32 AM
Hi msigman,

    It worked.... Thank you very much.

Regards,
John.
0
msigman
Top achievements
Rank 2
answered on 11 Jun 2013, 11:37 AM
John,

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

Thanks,
Matt
Tags
Ajax
Asked by
John
Top achievements
Rank 1
Answers by
msigman
Top achievements
Rank 2
John
Top achievements
Rank 1
Share this question
or