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

Problems adding a radtooltip to checkboxlist

4 Answers 100 Views
ToolTip
This is a migrated thread and some comments may be shown as answers.
Chad Johnson
Top achievements
Rank 1
Chad Johnson asked on 08 Jul 2009, 06:13 PM

Greetings,

I have a page that has a CheckboxList on it which needs to have tooltips also.  Seeing how CheckboxLists don't have that option, I decided to try using  a RadToolTip.  There is a problem though.  It causes an error.  Here is what I have thus far.

public void SetSelectedModules(DTOCoP cop)  
{  
            string url = BuildURL(Request.Url.ToString());  
 
            foreach (ListItem li in cblModules.Items)  
            {  
                var hit = (from a in cop.Modules where a.ModuleID == Int32.Parse(li.Value) select a).FirstOrDefault();  
                li.Selected = hit.Selected;  
                RadToolTip tip = new RadToolTip();  
                tip.RelativeTo = ToolTipRelativeDisplay.Element;  
                tip.Text = hit.Description;  
                tip.TargetControlID = li.Attributes["ID"];  
                tip.IsClientID = true;  
                this.cblModules.Controls.Add(tip);  
            }  

This is called during PageLoad, after setting the DataSource of the CheckboxList (cblModules).  The page loads fine till I click on one of the Checkboxes, in which I get an error saying "Input string was not in a correct format."  The only input I have is tip.Text, which receives a string.  If anyone has any ideas, or has a better way of instantiating a RadToolTip for a CheckboxList, I'll be thankful.  Thanks.

~Chad Johnson

4 Answers, 1 is accepted

Sort by
0
Svetlina Anati
Telerik team
answered on 09 Jul 2009, 12:03 PM
Hello Chad,

I built up a test demo based on your code but I was not able to reproduce the problem. However, teh tooltips do not show correctly because they should be added to the form as shown below:

  foreach (ListItem li in cblModules.Items)     
            {     
               // var hit = (from a in cop.Modules where a.ModuleID == Int32.Parse(li.Value) select a).FirstOrDefault();     
                li.Attributes.Add("ID", Guid.NewGuid().ToString());   
                li.Selected = true;     
                RadToolTip tip = new RadToolTip();     
                tip.RelativeTo = ToolTipRelativeDisplay.Element;     
                tip.Text = "Description";     
                tip.TargetControlID = li.Attributes["ID"];     
                tip.IsClientID = true;     
                this.form1.Controls.Add(tip);     
            }    

After I did this, everything started working as expected. After that I tested whether the problem is caused by encoding and included the special sign of apostrophe in the Text ( it became Desc'ription) but again everything worked as expected. I made my tests with the 2009.1.402 version as you have noted and also with the latest release.  Would ypou please examine the attached test page and let mw know what should I modify to replicate the problem on my side? 

Kind regards,
Svetlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Chad Johnson
Top achievements
Rank 1
answered on 09 Jul 2009, 12:41 PM
Thank you for your post, but I ran into a bit of a snag.  Whenever I tried your solution, I got the following error:  A page can have only one server-side Form tag.  I ponder if this is due that I'm in a MasterPage, or would that matter?  There are actually no forms on the page, though I added one using your example.  Any suggestions?
0
Accepted
Svetlina Anati
Telerik team
answered on 09 Jul 2009, 01:36 PM
Hi Chad,

The MasterPage itself contains a <form> element and the content page should not contain neither head, nor form nor body elements but the markup is just wrapped in ContentPlaceHolder, e.g as the one shown below:

<

 

asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

Please, note that this is general ASP.NET knowledge and it is not directly related to RadControls - incorporate the fix correctly and let us know about your results.

 




All the best,
Svetlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Chad Johnson
Top achievements
Rank 1
answered on 09 Jul 2009, 02:01 PM
Thanks so very much.  That worked perfectly once I tweaked it a bit.
Tags
ToolTip
Asked by
Chad Johnson
Top achievements
Rank 1
Answers by
Svetlina Anati
Telerik team
Chad Johnson
Top achievements
Rank 1
Share this question
or