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

XmlHttpPanel Callback Loading error

3 Answers 157 Views
XmlHttpPanel
This is a migrated thread and some comments may be shown as answers.
Anthony Solomon
Top achievements
Rank 1
Anthony Solomon asked on 25 Jan 2010, 06:29 AM

Hi All,

Hoping that someone can help:

I have a RadListView and within the RadListView in the item template, I have a RadRating component. This I have bound to a Linq result set and this all works perfectly. To prevent the entire page posting back when rating each RadRating control, I put the list view in an RadXmlHttpPanel and performed the database submission in the RadXmlHttpPanel_ServiceRequest event.

This all works great but then it returns, the error:
XmlHttpPanel Callback Loading error:
Exception=Script control 'ResponseRadRating' is not a registered script control. Script controls must be registered using RegisterScriptControl() before calling RegisterScriptDescriptors().
Parameter name: scriptControl

As mentioned in other posts, I have tried setting the EnableClientScriptEvaluation to "true" on the RadXmlHttpPanel and RegisterWithScriptManager to "false" on the RadRating controls that are in the Item template of the RadListView control. Once I have set these up, the RadXmlHttpPanel_ServiceRequest event no longer fires.

Does you have any suggestions?

3 Answers, 1 is accepted

Sort by
0
Pero
Telerik team
answered on 25 Jan 2010, 01:14 PM
Hi Anthony,

Based on the information provided, I think that you don't need to place the ListView together with the Rating control in the XmlHttpPanel, because you are not loading the content from the server but you make a callback only to save the values in the DataBase. This means that you can leave the XmlHttpPanel empty and use the RadRating's OnClientRated client-side event to initiate the XmlPanel's client callback and pass the values to the panel (i.e. XmlPanel.set_value(rated_value)) which on the other hand will pass the values in the DB.


Best wishes,
Pero
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.
0
Anthony Solomon
Top achievements
Rank 1
answered on 26 Jan 2010, 09:30 AM
Thanks very much for your response. This is the way I have set this up already:
.aspx file
RadXmlHttpPanel with the RadListView inside and the Rating - ClientRated() client side event
                 <div class="QARadListDiv">               
                     
                    <telerik:RadXmlHttpPanel LoadingPanelID="MasterRadAjaxLoadingPanel" ID="QARadXmlHttpPanel" runat="server"  
                        OnServiceRequest="QARadXmlHttpPanel_ServiceRequest" EnableClientScriptEvaluation="true"
                     
                        <telerik:RadListView ID="QARadListView" runat="server" ItemPlaceholderID="QAListViewPlaceHolder"  
                            AllowCustomPaging="True" AllowPaging="True" ToolTip="Please select the relevant assessment to complete."  
                            OnNeedDataSource="QARadListView_NeedDataSource" OnPageIndexChanged="QARadListView_PageIndexChanged"
                             
                            <LayoutTemplate> 
                                <telerik:RadScriptBlock ID="QARadScriptBlock" runat="server">   
                                    <script type="text/javascript"
                                        function QARadRating_ClientRated(sender, args) { 
                                            // Included as an extra attribute when binding 
                                            var assessmentResponseId = sender.get_element().getAttribute("assessmentresponseid"); 
 
                                            var answerIndex = sender.get_value(); 
                                            var panel = $find("<%=QARadXmlHttpPanel.ClientID %>"); 
                                            var ratedValues = assessmentResponseId + '|' + answerIndex; 
 
                                            panel.set_value(ratedValues); 
                                        }                
                                    </script>  
                                </telerik:RadScriptBlock>                            
                             
                                <div class="assessProgressDiv">Page <%# QARadListView.CurrentPageIndex + 1 %> of <%# QARadListView.PageCount %></div
                                <div style="float: left"
                                    <asp:PlaceHolder ID="QAListViewPlaceHolder" runat="server"></asp:PlaceHolder> 
                                    <br /> 
                                    <div style="clear: both;"
                                         
                                        <div class="buttonDiv"
                                            <asp:Button ID="QAPrevButton" runat="server" Text="Previous" ToolTip="Go to previous page of questions" CssClass="pageButton" OnClick="QAPrevButton_Click" Visible="<%# QARadListView.CurrentPageIndex > 0 %>" /> 
                                            <asp:Button ID="QANextButton" runat="server" Enabled="true" Text="Next" Tooltip="Go to next page of questions" CssClass="pageButton" OnClick="QANextButton_Click" Visible="<%# QARadListView.CurrentPageIndex < QARadListView.PageCount -1 %>" /> 
                                            <asp:Button ID="AssessmentFinishButton" runat="server" Text="Finish" CssClass="pageButton" OnClick="AssessmentFinishButton_Click" Visible="<%# QARadListView.CurrentPageIndex == QARadListView.PageCount -1 %>" /> 
                                        </div> 
                                    </div> 
                                </div> 
                            </LayoutTemplate>                
                         
                            <ItemTemplate> 
                                <div class="questionRowDiv"
                                    <div class="numberDiv" > 
                                        <%# (Container.DisplayIndex + 1) + ((Container.OwnerListView.CurrentPageIndex) * Container.OwnerListView.PageSize) %>
                                    </div> 
                                    <div class="questionTextDiv"
                                        <%# DataBinder.Eval(Container.DataItem, "QuestionText") %> 
                                    </div> 
                                    <div class="responseDiv"
                                        <telerik:RadRating ID="ResponseRadRating" runat="server" Skin="Simple" RegisterWithScriptManager="true"  
                                            ItemCount='<%# AnswerCount %>' SelectionMode="Single" Value='<%# GetRatingIndexFromAnswerId(Convert.ToInt32(Eval("AnswerId"))) %>'  
                                            ToolTip="Please select an answer that is most acurate"  
                                            OnClientLoad="RadRating_ClientLoad" OnClientRated="QARadRating_ClientRated"  
                                            assessmentresponseid='<%# Eval("Id") %>' 
                                        />       
                                    </div> 
                                </div> 
                            </ItemTemplate>      
                             
                            <AlternatingItemTemplate> 
                                <div class="questionRowDivAlt"
                                    <div class="numberDiv"
                                        <%# (Container.DisplayIndex + 1) + ((Container.OwnerListView.CurrentPageIndex) * Container.OwnerListView.PageSize) %>
                                    </div>                           
                                    <div class="questionTextDiv"
                                        <%# DataBinder.Eval(Container.DataItem, "QuestionText") %>                   
                                    </div> 
                                    <div class="responseDiv"
                                        <telerik:RadRating ID="ResponseRadRating" runat="server" Skin="Simple" RegisterWithScriptManager="true" 
                                            ItemCount='<%# AnswerCount %>' SelectionMode="Single" Value='<%# GetRatingIndexFromAnswerId(Convert.ToInt32(Eval("AnswerId"))) %>'  
                                            ToolTip="Please select an answer that is most acurate" 
                                            OnClientLoad="RadRating_ClientLoad" OnClientRated="QARadRating_ClientRated" 
                                            assessmentresponseid='<%# Eval("Id") %>' 
                                        />       
                                    </div> 
                                </div> 
                            </AlternatingItemTemplate>                                   
                        </telerik:RadListView>                   
 
                    </telerik:RadXmlHttpPanel> 
                </div>   



.cs file
Service Request Method:
protected void QARadXmlHttpPanel_ServiceRequest(object sender, RadXmlHttpPanelEventArgs e) 
    // Code to store values extracted from e.Value in the database. 


What's happening, however, is when the response comes back from the server and the ServerRequest method has completed and stored the information in the database, I get the error:

"XmlHttpPanel Callback Loading error:
 Exception=Script control 'ResponseRadRating' is not a registered script control. Script controls must be registered using RegisterScriptControl() before calling RegisterScriptDescriptors().

Parameter name: scriptControl"

0
Pero
Telerik team
answered on 29 Jan 2010, 09:09 AM
Hi Anthony,

Thank you for the code. After some changes I did manage to run it locally. At first I got the same error you get, but after setting RegisterWithScriptManager="false" to the rating controls the errors disappeared. I have attached the modified project to the thread.

Please consider the following when using the XmlHttpPanel control:

  • Place only the needed content (the want that you need to update) in the panel. For example the client script that initializes the callback is never modified but is always sent back from the server. This creates additional load to the server response.
  • I noticed that you have attached server-side event handlers to the events of (almost) all your Button controls and the RadListView control. Please note that when using ASP.NET callbacks the page does not go through its full life-cycle and there is no ViewState. Also, a full postback will occur if one of the buttons is pressed (not a callback). That is why in scenarios when you try to interact with the server to edit and modify the data in the XmlHttpPanel we recommend using AJAX panel instead.



Regards,
Pero
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.
Tags
XmlHttpPanel
Asked by
Anthony Solomon
Top achievements
Rank 1
Answers by
Pero
Telerik team
Anthony Solomon
Top achievements
Rank 1
Share this question
or