Ajaxify Control After Page Prerender

6 posts, 0 answers
  1. Tawab
    Tawab avatar
    5 posts
    Member since:
    Jun 2011

    Posted 21 Oct 2015 Link to this post

    Hi, I'm wondering if there is a way to dynamically ajaxify controls outside of a page load / postback event.  The specific scenario is that I have a grid that updates a user control.  The user control acts as a detail area for the items in the grid.  I would like to make it so a page or sort event on the grid does not update the user control, but a row edit or insert event does.  I tried doing this by creating a client event to handle the grid click.  If insert or edit row is clicked, I call a code-behind method to enable the user control update (calling AddAjaxSetting, and then later removing the Ajax setting).  But when I tried this, I got this error:

     

    Controls cannot be ajaxified after page prerender

     

    Is there another way to accomplish my goal, without doing a postback/reload of the page?  Thanks.

  2. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 22 Oct 2015 Link to this post

    Hi Tawab,

    You can use the EventName property of the AjaxSettings and set the "EditCommand" and "InsertCommand" as event names for updating the specific UserControl.
    Give this a try and see if it helps.

    Regards,
    Maria Ilieva
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Tawab
    Tawab avatar
    5 posts
    Member since:
    Jun 2011

    Posted 23 Oct 2015 in reply to Maria Ilieva Link to this post

    I wasn't sure how to add more than one event name, but when I added EventName="InsertCommand" the code stopped working.  Here is what I have:

    <telerik:AjaxSetting AjaxControlID="rgTaskList" EventName="InsertCommand">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="pnlTaskDetails" LoadingPanelID="ralpTaskList"/>
                        <telerik:AjaxUpdatedControl ControlID="rgTaskList" LoadingPanelID="ralpTaskList"/>
                        <telerik:AjaxUpdatedControl ControlID="lblUserInfo" LoadingPanelID="ralpDummy" />
                        <telerik:AjaxUpdatedControl ControlID="lblMessage" LoadingPanelID="ralpDummy" />
                    </UpdatedControls>
                </telerik:AjaxSetting>

    Before adding the EventName, when I clicked rgTaskList it would update pnlTaskDetails after making it visible (if hidden).  But after adding the EventName, when I click rgTaskList the pnlTaskDetails is still hidden.  I checked the code-behind and there is no exception being generated, so somehow the simple act of adding the EventName ​prevents my code from showing pnlTaskDetails.  Any ideas on this?  Thanks.

  5. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 26 Oct 2015 Link to this post

    Hi,

    By setting EventName the corresponding UdpatedControl will be updated only when this specific event is executed by the RadGrid. I'm not sure what you mean exactly by "click on rgTaskList " but in this configuration the panel will be updated only when InsertCommand executes. Depends on the action  that need to be taken for updating the specific panels you can set different EventNames

    Regards,
    Maria Ilieva
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  6. Tawab
    Tawab avatar
    5 posts
    Member since:
    Jun 2011

    Posted 29 Oct 2015 in reply to Maria Ilieva Link to this post

    Sorry, by "click on rgTaskList" I meant click the button on the grid that fires the "InsertCommand" event.  Per the markup above, this is supposed to update pnlTaskDetails, but instead it is preventing some other code from even showing pnlTaskDetails (it remains hidden after the click, so even if it is updated we can't see it).  If I remove EventName="InsertCommand" above, then everything works, meaning pnlTaskDetails is shown and updated.  I've tried adding more code to make pnlTaskDetails visible manually, but to no avail.  I will need to do further analysis on this.  Meanwhile, assuming I can get the behavior working, can you tell me how to add multiple events to EventName?  I want to do something like this: EventName="InsertCommand, EditCommand".  Thanks.
  7. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 29 Oct 2015 Link to this post

    Hello,

    In order to add multiple EventNames you should add multiple Ajax settings with the same AjaxControlID, but with different EventNames.

    Regards,
    Maria Ilieva
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017