Im getting Value cannot be null. Parameter name: page with repeater

6 posts, 0 answers
  1. Nicole
    Nicole avatar
    4 posts
    Member since:
    Oct 2013

    Posted 10 Oct 2013 Link to this post

    Hi,

    I have a page with a repeater inside a Panel. Inside the repeater, there's a radiobuttonlist and depends on what the user clicks, I have to add new rows to the repeater. The problem is I'm getting this error:

    Value cannot be null.
    Parameter name: page


    My aspx page is like this:
     <asp:Panel runat="server" ID="updPnlQuestionnaire">
                        <%--<ContentTemplate>--%>
                             <asp:Repeater ID="rptrQuestion" runat="server" OnItemDataBound="rptrQuestion_OnItemDataBound" OnItemCreated="rptrQuestion_OnItemCreated" ClientIDMode="AutoID">
                                    <ItemTemplate>
                                        <table class='questions-table'>
                                                <tr class='datarow'>
                                                    <td><asp:Label ID="lblQuestion" Text='<%# Eval("Question") %>' runat="server"></asp:Label>
                                                        <asp:HiddenField ID="hdnQuestionType" runat="server" Value='<%# Eval("QuestionType") %>'/>
                                                        <asp:HiddenField ID="hdnQuestionID" runat="server" Value='<%# Eval("QuestionID") %>'/>
                                                    </td>
                                                </tr>
                                         </table>
                                         <table class="questions-table">
                                            <tr class="datarow">
                                                <td>
                                                    <asp:RadioButtonList ID="rblListAnswers" runat="server" OnSelectedIndexChanged="rblListAnswers_OnSelectedIndexChanged" AutoPostBack="true"></asp:RadioButtonList>
                                                </td>
                                            </tr>
                                           
                                        </table>
                                    
                                    </ItemTemplate>
                                </asp:Repeater>
                            
                        </asp:Panel>

    While in my Item_Created, I'm adding the ajaxsettings:
     protected void rptrQuestion_OnItemCreated(object sender, RepeaterItemEventArgs e)
            {
                RadioButtonList rblListAnswers = (RadioButtonList)e.Item.FindControl("rblListAnswers");
                var ajaxManager = RadAjaxManager.GetCurrent(this.Page);
                    ajaxManager.AjaxSettings.AddAjaxSetting(rblListAnswers, updPnlQuestionnaire);
            }

    I've read somewhere that adding ClientIDMode="AutoID" solves this problem, but I'm still having this issue. Even adding the ajaxsettings in OnItemDataBound still gives this error.

    Any help would be greatly appreciated. Thanks!
  2. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1796 posts

    Posted 14 Oct 2013 Link to this post

    Hi Nicole,

    The error that you are receiving is due to the fact that the Page property of the RadioButtonList control that you are setting as an initiator is null. 

    Actually, for your scenario you do not need to add the RadButtonList controls as initiators at all. Instead, you should add either the Repeater control or the Panel as initiator and as updated control. In almost every cases, when you ajaxify control, all nested controls are getting ajaxified too. Thus means that if you ajaxify the Repeater, all nested RadButtonList controls will make an AJAX request and will update the Repeater with its nested controls.

    Notwithstanding, there is a way to overcome the error that you are receiving by just setting the Page property of the RadButonList controls, before adding the AjaxSetting:
    updPnlQuestionnaire.Page = this.Page;
    *Keep in mind that this approach is not recommended and is absolutely unnecessary.

    Here is the recommended approach for your scenario:
    protected void Page_Load(object sender, EventArgs e)
    {
        var ajaxManager = RadAjaxManager.GetCurrent(this.Page);
        ajaxManager.AjaxSettings.AddAjaxSetting(updPnlQuestionnaire, updPnlQuestionnaire);
    }

    Hope that helps.

     

    Regards,
    Konstantin Dikov
    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 RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Nicole
    Nicole avatar
    4 posts
    Member since:
    Oct 2013

    Posted 16 Oct 2013 Link to this post

    Hi Konstantin,

    Thank you for your reply. The error is gone now after I make the changes as you have said; however, it only works once. After I click on the radio button once, I get the desired results, but when the next set of radiobuttonlist shows up, no events (onselectedindexchanged) are being fired anymore..

    Moreover, in my page, there's a back button which performs Server.Transfer to another url, when I click on it, it returns Resource Not Found 404 error. Does this have anything to do with the loss of the events after using AJAX?

    Please advise why this is so.
    Thanks! Appreciate any help!
  5. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1796 posts

    Posted 21 Oct 2013 Link to this post

    Hello Nicole,

    Please refer to the attached sample pages working as expected on my end and see what differs in your project.

    If further assistance is needed and in order for us to be able to help you with the issue, please open a regular support ticket with sample, runnable project that replicates the problematic behavior, and send it for further inspection.

     

    Regards,
    Konstantin Dikov
    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 RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  6. Nicole
    Nicole avatar
    4 posts
    Member since:
    Oct 2013

    Posted 21 Oct 2013 Link to this post

    Hi Konstantin,

    I noticed in your sample project, there's no ClientIDMode="Auto" attribute for the RadioButtonList. However, In my case, if I remove that, it won't work even once. If I add it however, ajax only works once but not on succeeding clicks. Moreover, my panel is actually inside a RadPageView:

    <telerik:RadMultiPage ID="RadMultiPage1" runat="server" SelectedIndex="1" Width="100%">
         <telerik:RadPageView ID="pvstep1" runat="server">
    Can this have affected anything? My RadScriptManager and RadAjaxManger is in the master page.

    I have used Chrome to debug my page, and it turns out on the second click, Im encountering this issue again: 
    Uncaught Sys.WebForms.PageRequestManagerServerErrorException: Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 404
     
    I keep encountering this issue whenever I use AjaxSettings or Asp:updatepanel. Am I missing something? When I comment out Ajax, I do not encounter any errors so I'm  quite certain nothing is wrong from my C# code. I'm already adding the scriptreference in my master page:

    <telerik:RadScriptManager ID="radScriptManager" runat="server">
            <Scripts>
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
            </Scripts>
        </telerik:RadScriptManager>

    Also, using Fiddler, I noticed that at the second postback, my url is being changed from http://localhost/Questionnaire/Question.aspx to only http://localhost/Question.aspx, which maybe is causing this 404 resource not found. I don't understand why using Ajax will alter this. Please advise.

    Thanks! Your help is greatly appreciated!
  7. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1796 posts

    Posted 23 Oct 2013 Link to this post

    Hi Nicole,

    The default value of ClientIDMode is "Auto" and that is the reason that i have removed it in my sample page. Please note that RadControls are complex controls that could only work with ClientIDMode set to "Auto".

    About the error you are receiving you could take a look at our help article "Web Resources Troubleshooting".

    Additionally, you could try replacing Server.Transfer with Response.Redirect and see if it makes any difference. Also, please ensure that you do not have nested AJAX settings that could also lead to the error you are receiving.

    Hope that helps with your issues.

     

    Regards,
    Konstantin Dikov
    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 RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017