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

RadToolTip inside RadComboBox not displaying after postback

1 Answer 110 Views
ToolTip
This is a migrated thread and some comments may be shown as answers.
Cynthia Stone
Top achievements
Rank 1
Cynthia Stone asked on 26 Oct 2009, 09:03 PM
I have a RadComboBox that is populated in the code-behind. I am attaching a tool tip to each item in the combo box. Each tool tip displays on the page load but once the page is postback (there are other controls on the page that have AutoPostBack=True), the tool tips no longer display.

'in aspx page

<telerik:RadComboBox ID="RadComboPriority" runat="server" Width="280px" TabIndex="7" CssClass="blackText9" AllowCustomText="false"></telerik:RadComboBox>
  

'populating the RadComboBox on PageLoad

Public Sub LoadPriorities()
        Dim description As String
        Dim item As New RadComboBoxItem()
        item.Text = ""
        item.Value = 0
        RadComboPriority.Items.Add(item)

        Dim item1 As New RadComboBoxItem()
        item1.Text = "1 - Immediate"
        item1.Value = 1
        description = "Use this code when you are not able to do your job."
        ToolTipify(item1, description)
        RadComboPriority.Items.Add(item1)

        Dim item2 As New RadComboBoxItem()
        item2.Text = "2 - Serious"
        item2.Value = 2
        description = "For when you are able to do your job, but you are limited by a problem."
        ToolTipify(item2, description)
        RadComboPriority.Items.Add(item2)

        Dim item3 As New RadComboBoxItem()
        item3.Text = "3 - Minor"
        item3.Value = 3
        description = "This code is used when you need help but can wait until the priority 1 and 2 work orders are handled first."
        ToolTipify(item3, description)
        RadComboPriority.Items.Add(item3)
    End Sub

 

 

 

 

'adding tool tip to each item
Public Sub ToolTipify(ByVal item As RadComboBoxItem, ByVal description As String)
        Dim tip As New RadToolTip()
        item.Attributes.Add("ID", Guid.NewGuid().ToString())
        tip.RelativeTo = ToolTipRelativeDisplay.Element
        tip.Text = description
        tip.TargetControlID = item.Attributes("ID")
        tip.IsClientID = True
        'tip.ShowEvent = ToolTipShowEvent.FromCode
        'form1.Controls.Add(tip)
        tip.VisibleOnPageLoad = True
        tip.HideEvent = ToolTipHideEvent.LeaveToolTip
        Me.Page.Form.Controls.Add(tip)
    End Sub

 

I am unable to get the tool tips to display after the page has been posted back. Any help would be appreciated.
Thanks,
Cindy

 

 

 

 

 

 

 

 

 

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Svetlina Anati
Telerik team
answered on 29 Oct 2009, 09:11 AM
Hi Cynthia,

From the posted code and your explanations, I assume that you execute the code only on initial load as shown below:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
       If Not (Page.IsPostBack) Then
           LoadPriorities()
       End If
   End Sub

If so, please note that when you dynamically create controls, you should take care to recreate them after the postback and in this case it is expected that they disappear (you can test this by e.g adding a standard asp button instead of a tooltip - you will get the same result). More information about dynamically added controls is available in the article below (the section about their recreation is some paragraphs below teh beginning ):

http://couldbedone.blogspot.com/2007/06/dynamically-created-controls-in-aspnet.html

I hope that my explanation and teh provided resource are helpful.


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.
Tags
ToolTip
Asked by
Cynthia Stone
Top achievements
Rank 1
Answers by
Svetlina Anati
Telerik team
Share this question
or