UserControl in ToolTipManager - Events not firing

3 posts, 0 answers
  1. Landon Martin
    Landon Martin avatar
    6 posts
    Member since:
    Oct 2009

    Posted 11 Nov 2009 Link to this post

    I have a ToolTipManager on  a page when a button is clicked loads a UserControl based off of which item is clicked.  In this particular instance it has two dropdowns and a textbox.  It also has a save button.  The problem I am having is that I cannot get any event to trigger inside the tooltip.  When I click my save button the OnAjaxUpdate event fires but the button click event does not.  Here is what I have codewise:
    In my page:
    <telerik:RadToolTipManager ID="tltAvailability" runat="server" OnAjaxUpdate="OnAjaxUpdate" RelativeTo="Element" 
                                                                               ShowEvent="OnClick" HideEvent="ManualClose" 
                                                                               Position="MiddleLeft" Animation=FlyIn RenderInPageRoot="true" Width="250" Height="200" 
                                                                                ></telerik:RadToolTipManager> 

    The user control:
    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="repAvailability.ascx.cs" Inherits="cox.applications.web.ehealth.physicianreferral.AvailabilityToolTip" %> 
    <%@ Reference Control="~/tooltipcontent/ToolTipContent.ascx" %> 
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
    <script type="text/javascript">  
     
    </script> 
    <asp:FormView ID="fvwAvailability" runat="server" OnItemCreated="CreatedFormItem" OnItemCommand="fvwAvailability_ItemCommand" > 
        <ItemTemplate>          
          
            Type of Availability:<br /> 
            <telerik:RadComboBox ID="ddlTypes" runat="server" DataValueField="ID" DataTextField="Description" ZIndex="10000"          
                                  AutoPostBack="true" OnSelectedIndexChanged="SelectedType">                                 
                                 </telerik:RadComboBox><br /> 
            Age Available:<br /> 
            <asp:TextBox ID="txtAge" runat="server" Width="75px" ></asp:TextBox><br /> 
            Range of Availbility:<br /> 
            <telerik:RadComboBox ID="ddlRange" runat="server" DataTextField="Description" DataValueField="ID" ZIndex="10000" >       
            </telerik:RadComboBox><br />                  
        </ItemTemplate>      
    </asp:FormView> 
    <asp:Button ID="btnSave" runat="server" OnClick="SaveClicked" Text="Save" UseSubmitBehavior="false" /> 
    Here's the code AjaxCode:
            protected void OnAjaxUpdate(object sender, ToolTipUpdateEventArgs args)  
            {  
                _currentPhysician = Shared.CurrentPhysician;  
                string[] values = args.Value.Split('|');  
                if (values.Length > 0)  
                {  
                    Control saveButton = this.UpdateToolTip(values[0], args.UpdatePanel, int.Parse(values[1]));  
                }      
            }    
     
            private Control UpdateToolTip(string section, UpdatePanel update, int index)  
            {  
                ToolTipContent ctl = (ToolTipContent)Page.LoadControl("tooltipcontent/" + section + ".ascx");  
                ctl.SetIndex(index);  
                update.ContentTemplateContainer.Controls.Add(ctl);  
                return ctl.SaveButton;              
            }        
     
    /* THIS CODE IS FROM THE USER CONTROL */ 
            public void SetIndex(int index)  
            {  
                _index = index;  
                SetDataSource();  
            }  
     
            protected override void SetDataSource()  
            {              
                if (this._index >= 0)  
                {  
                    List<AvailabilityInfo> inf = Shared.CurrentPhysician.AvailabilityInfo;  
     
                    fvwAvailability.DataSource = (from i in inf  
                                                  where inf.IndexOf(i) == this._index  
                                                  select i);  
     
                    _baseInfo = (ApprovableItem)fvwAvailability.DataItem;  
                }  
                else 
                {  
                    fvwAvailability.DataSource = null;  
                    _baseInfo = new ApprovableItem(Null.NullInteger, StatusType.Pending, Null.NullInteger, Null.NullDate, Shared.User, Null.NullString);  
                }  
                fvwAvailability.DataBind();          
            }  
     
            protected void SaveClicked(object sender, EventArgs e)  
            {  
                SaveInfo();  
            } 

    The code in SaveInfo is irrelevant because SaveClicked is not even firing! A huge thank you in advance for any help I can get as I'm pushing deadline.
  2. Svetlina Anati
    Admin
    Svetlina Anati avatar
    2795 posts

    Posted 13 Nov 2009 Link to this post

    Hi Landon,

    When you are using AJAX, the scripts do not get correctly parsed because of the fact that the update panel uses the innerHTML property and you should dynamically evaluate the scripts if you want them to be recognized as such. This is related to the way the MS AJAX Framework works and it is not directly related to the RadControls and RadToolTipManager. However, since the manager loads its content through AJAX in your scenario, you experience this general issue.

    For such cases, we have prepared a blog post which explains this problem and also offers a sample solution. The blog post has also attached a demo which reproduces the problem without usage of any RadControls and also has the suggested workaround implemented. I believe that this post will be helpful - you can find it below:

    http://blogs.telerik.com/tervelpeykov/posts/08-10-20/ajax_using_ajax_to_load_a_usercontrol_that_has_javascript_declared_in_it.aspx

    The solution in the blogpost is pretty complex and it does not work in some partcular cases. Another solution is to register your scripts from teh user control's code-behind as explained below:

    http://blogs.telerik.com/blogs/posts/09-05-05/executing_javascript_function_from_server-side_code.aspx

    Please, examine the provided resources, find the better solution for your case and let us know how itt goes.



    Greetings,
    Svetlina
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Landon Martin
    Landon Martin avatar
    6 posts
    Member since:
    Oct 2009

    Posted 17 Nov 2009 Link to this post

    I thought I had already posted this before, but apparently not!  My issue was because of the formview.  I still don't know exactly why but after I databound the formview my events would no longer fire.  I removed the formview and chose another method of populating my controls and the save button works without any additional work.
Back to Top