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
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
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.
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
In order to add multiple EventNames you should add multiple Ajax settings with the same AjaxControlID, but with different EventNames.
Regards,
Maria Ilieva
Telerik