Value cannot be null. While Adding AjaxSettings

5 posts, 1 answers
  1. Gotcha
    Gotcha avatar
    64 posts
    Member since:
    Sep 2009

    Posted 25 Nov 2011 Link to this post

    Hi,

    I have an asp repeater and i wanted to ajaxify the linkbutton on itemcreated but i am getting an error message. Can you please let me know what I am doing wrong?

    Error: Value cannot be null, Parameter Page
    at Telerik.Web.UI.RadAjaxManager.GetCurrent(Page page)
    at Telerik.Web.UI.AjaxSettingsCollection.AddAjaxSetting(Control ajaxifiedControl, Control updatedControl, RadAjaxLoadingPanel loadingPanel, UpdatePanelRenderMode renderMode, Unit updatePanelHeight)
    at Telerik.Web.UI.AjaxSettingsCollection.AddAjaxSetting(Control ajaxifiedControl, Control updatedControl, RadAjaxLoadingPanel loadingPanel, UpdatePanelRenderMode renderMode)
    at Telerik.Web.UI.AjaxSettingsCollection.AddAjaxSetting(Control ajaxifiedControl, Control updatedControl, RadAjaxLoadingPanel loadingPanel)
    at Telerik.Web.UI.AjaxSettingsCollection.AddAjaxSetting(Control ajaxifiedControl, Control updatedControl)
    at com.celero.los_2.WebApp.Controls.Popups.CollateralAssetListControl.rptAssetList_ItemCreated(Object sender, RepeaterItemEventArgs e)
    at System.Web.UI.WebControls.Repeater.OnItemCreated(RepeaterItemEventArgs e)
    at System.Web.UI.WebControls.Repeater.CreateItem(Int32 itemIndex, ListItemType itemType, Boolean dataBind, Object dataItem)
    at System.Web.UI.WebControls.Repeater.CreateControlHierarchy(Boolean useDataSource)
    at System.Web.UI.WebControls.Repeater.OnDataBinding(EventArgs e)
    at System.Web.UI.WebControls.Repeater.DataBind()
    at com.celero.los_2.WebApp.Controls.Popups.CollateralAssetListControl.BindAssetGrid()
    at com.celero.los_2.WebApp.Controls.Popups.CollateralAssetListControl.Page_Load(Object sender, EventArgs e)
    at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
    at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
    at System.Web.UI.Control.OnLoad(EventArgs e)
    at com.celero.los_2.WebApp.PresentationLogic.UserControlBase.OnLoad(EventArgs e)
    at System.Web.UI.Control.LoadRecursive()
    at System.Web.UI.Control.AddedControl(Control control, Int32 index)
    at System.Web.UI.ControlCollection.Add(Control child)
    at com.celero.los_2.WebApp.Framework.ModalPopup.ModalPopupControl.LoadContentControl()
    at com.celero.los_2.WebApp.Framework.ModalPopup.ModalPopupControl.OpenPopup()
    at com.celero.los_2.WebApp.Pages.Collateral.btnAddCollateralAsset_Click(Object sender, EventArgs e)
    at System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e)
    at System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument)
    at System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
    at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
    at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
    at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)



    Below is the HTML mark up
    <asp:Repeater ID="rptAssetList" runat="server" EnableViewState="false" OnItemCommand="rptAssetList_ItemCommand" OnItemCreated="rptAssetList_ItemCreated">
        <ItemTemplate>
            <tr class="GridRow">
                <td>
                    <asp:LinkButton ID="btnSelectAsset" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "ASSLIB_TYPE")%>'
                        CommandName="Select" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "ASSLIB_ID")%>'>
                    </asp:LinkButton>
                </td>
                <td>
                    <div>
                        <%# DataBinder.Eval(Container.DataItem, "DESCRIPTION")%>
                    </div>
                </td>
                <td>
                    <div style="text-align: right;">
                        <%# DataBinder.Eval(Container.DataItem, "BALANCE", "{0:c}")%>
                    </div>
                </td>
            </tr>
        </ItemTemplate>
        <AlternatingItemTemplate>
            <tr class="GridAlternRow">
                <td>
                    <asp:LinkButton ID="btnSelectAsset" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "ASSLIB_TYPE")%>'
                        CommandName="Select" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "ASSLIB_ID")%>'>
                    </asp:LinkButton>
                </td>
                <td>
                    <div>
                        <%# DataBinder.Eval(Container.DataItem, "DESCRIPTION")%>
                    </div>
                </td>
                <td>
                    <div style="text-align: right;">
                        <%# DataBinder.Eval(Container.DataItem, "BALANCE", "{0:c}")%>
                    </div>
                </td>
            </tr>
        </AlternatingItemTemplate>
    </asp:Repeater>

    The code Behind. I'm bascially adding an ajax setting on the btnSelectAsset on 4 asp Panel below.
    And the Error is "Value cannot be null"
    protected void rptAssetList_ItemCreated(object sender, RepeaterItemEventArgs e)
    {
     
        if (e.Item.ItemType == ListItemType.AlternatingItem ||
                                    e.Item.ItemType == ListItemType.Item)
        {
            LinkButton btnSelectAsset = (LinkButton)e.Item.FindControl("btnSelectAsset");
            if (btnSelectAsset != null)
            {
                RadAjaxManagerProxy1.AjaxSettings.AddAjaxSetting(btnSelectAsset, pnlShortTerm);
                RadAjaxManagerProxy1.AjaxSettings.AddAjaxSetting(btnSelectAsset, pnlPropertyFields);
                RadAjaxManagerProxy1.AjaxSettings.AddAjaxSetting(btnSelectAsset, pnlPpsa);
                RadAjaxManagerProxy1.AjaxSettings.AddAjaxSetting(btnSelectAsset, pnlVehicle);
            }
        }
    }
  2. Mira
    Admin
    Mira avatar
    1124 posts

    Posted 30 Nov 2011 Link to this post

    Hello Gotcha,

    If you need to add AJAX settings programmatically in a usercontrol / content page, it is recommended to get the master manager instance and call its methods/properties as well. You can review the RadAjaxManagerProxy topic for additional information.

    I hope this helps.

    Greetings,
    Mira
    the Telerik team
    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 their blog feed now
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Gotcha
    Gotcha avatar
    64 posts
    Member since:
    Sep 2009

    Posted 30 Nov 2011 Link to this post

    Sorry I'm confused by your answer...
    Are you saying that I should not be using the following:
    RadAjaxManagerProxy1.AjaxSettings.AddAjaxSetting(btnSelectAsset, pnlShortTerm);


    but instead  use the RadAjaxManager from the Master Template ...soemthing like:

    RadAjaxManager1.AjaxSettings.AddAjaxSetting(btnSelectAsset, pnlShortTerm);

    where RadAjaxManager1 is the instance i n my Master Template?

    Thanks
  5. Answer
    Mira
    Admin
    Mira avatar
    1124 posts

    Posted 02 Dec 2011 Link to this post

    Hello Gotcha,

    Please try using the following code for adding the AJAX setting and let me know whether it helps:
    RadAjaxManager.GetCurrent(Page).AjaxSettings.AddAjaxSetting(btnSelectAsset, pnlShortTerm);

    I am looking forward to your reply.

    All the best,
    Mira
    the Telerik team
    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 their blog feed now
  6. James
    James avatar
    4 posts
    Member since:
    Apr 2012

    Posted 19 Aug 2013 Link to this post

    For our situation, the fix was to put the RadAjaxManager.AjaxSettings.AddAjaxSetting after adding the panel to the Controls (Controls.Add(panel)).
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017