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

callback from tooltip

4 Answers 124 Views
ToolTip
This is a migrated thread and some comments may be shown as answers.
Morten
Top achievements
Rank 2
Iron
Iron
Veteran
Morten asked on 03 Jun 2008, 09:49 PM
On a page I have a tooltip manager and a radgrid.
In every grid row I add a tooltiptargetcontrol to an image.
Image.OnClick pops up the tooltip that loads a usercontrol with data specific to the grid row.

I would like the tooltip to reload the grid (using ajax) upon the OnClientHide event.

Is this possible?

4 Answers, 1 is accepted

Sort by
0
Tervel
Telerik team
answered on 04 Jun 2008, 06:36 AM
Hello Morten,

Here is how you should approach the task:

1. Wrap your RadGrid into a regular <asp:UpdatePanel>

2. In the OnClientHide of the tooltip, all you need to do is "submit" the update panel, which can be done like this:
function refreshGrid()  
            {  
                __doPostBack("<%= RadGridUpdatePanel.ClientID %>");   
            } 


All the best,
Tervel
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Morten
Top achievements
Rank 2
Iron
Iron
Veteran
answered on 04 Jun 2008, 01:05 PM
the entire page is wrapped in <telerik:RadAjaxPanel ID="rap" runat="server">.

If I place the following code within the masterpage contentplaceholder:

<script type="text/javascript">
function OnClientHide(sender, eventArgs){
  __doPostBack("<%= rap.ClientID %>");
}
</script>

I get the following error on page load:

The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 

Stack Trace:


[HttpException (0x80004005): The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).]
   System.Web.UI.ControlCollection.AddAt(Int32 index, Control child) +2108046
   Telerik.Web.UI.RadAjaxControl.MoveUpdatePanel(Control initiator, Control updated) +110
   Telerik.Web.UI.RadAjaxControl.PerformRender() +418
   Telerik.Web.UI.RadAjaxControl.OnPageRender(HtmlTextWriter writer, Control page) +1222
   Telerik.Web.UI.RadAjaxControl.RenderPageInAjaxMode(HtmlTextWriter writer, Control page) +87
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +98
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +20
   System.Web.UI.Page.Render(HtmlTextWriter writer) +26
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2558

Hovering the grid's refresh button I get the following reference:
///__doPostBack('ctl00$cph$rg$ctl00$ctl02$ctl00$RebindGridButton','');

couldn't I, somehow, do something like this:

function OnClientHide(sender, eventArgs){
  __doPostBack('<%= rg.ClientID %>$RebindGridButton','');
}

0
Tervel
Telerik team
answered on 04 Jun 2008, 01:33 PM
Hi Morten,

This error is a general ASP.NET problem. You need to put the code somewhere on the page in a control that does not have its controls collection directly modified from the codebehind. Or you need to "output" this javascript function from the codebehind as well - forming a script string, and registering it on the page using the ScriptManager methods for adding scripts.

Regards,
Tervel
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Morten
Top achievements
Rank 2
Iron
Iron
Veteran
answered on 04 Jun 2008, 01:50 PM
I got things to work by involving a hidden button, wrapping the js in a RadScriptBlock, and simulating a button click in the OnClientHide:

<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
  <script type="text/javascript">
  function OnClientHide(sender, eventArgs)  {
    var btn = document.getElementById('<%= btnRefresh.ClientID %>');
    if (btn){btn.click();}
  }
  </script>
</telerik:RadScriptBlock>

<asp:Button ID="btnRefresh" runat="server" Text="Refresh" style="visibility:hidden ;" />

  Protected Sub btnRefresh_Click(ByVal sender As Object, _
                                 ByVal e As System.EventArgs) _
            Handles btnRefresh.Click
    rg.Rebind()
  End Sub
Tags
ToolTip
Asked by
Morten
Top achievements
Rank 2
Iron
Iron
Veteran
Answers by
Tervel
Telerik team
Morten
Top achievements
Rank 2
Iron
Iron
Veteran
Share this question
or