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

Ajaxify Control After Page Prerender

5 Answers 71 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Tawab
Top achievements
Rank 1
Tawab asked on 21 Oct 2015, 09:15 PM

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.

5 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 22 Oct 2015, 02:18 PM
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
0
Tawab
Top achievements
Rank 1
answered on 23 Oct 2015, 08:01 PM

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.

0
Maria Ilieva
Telerik team
answered on 26 Oct 2015, 11:28 AM
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
0
Tawab
Top achievements
Rank 1
answered on 29 Oct 2015, 05:40 AM
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.
0
Maria Ilieva
Telerik team
answered on 29 Oct 2015, 11:48 AM
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
Tags
Ajax
Asked by
Tawab
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Tawab
Top achievements
Rank 1
Share this question
or