Greetings,
I have a checkboxlist on a page to which I am trying to add tooltips to. I finally managed to find some code that placed them onto it during the load of the page, but whenever I do a postback, they will not return, no matter what I seem to do to them. Here is the code for what I'm doing.
When the OnSelectedIndexChanged event is fired, LoadTooltips is called at the end to rebuild the Tooltips for the cblModules. Unfortunately, nothing happens. Here is the code I use to build the Tooltips if it helps.
Again, it works on the first time through, when there is no Postback, but when I cause a Postback (clicking on cblModules), the tooltips vanish. If anyone has any ideas or a better solution, I'd be very appreciative.
~Chad Johnson
I have a checkboxlist on a page to which I am trying to add tooltips to. I finally managed to find some code that placed them onto it during the load of the page, but whenever I do a postback, they will not return, no matter what I seem to do to them. Here is the code for what I'm doing.
| //I cut out part of the code that does other things, but this is basically the same |
| protected void Page_Load(object sender, EventArgs e) |
| { |
| if (!IsPostBack) |
| //CoP is just a Session variable that is pulled into a property |
| LoadValues(CoP); |
| LoadTooltips(); |
| } |
| //Called after checkboxlist is built |
| private void LoadTooltips() |
| { |
| foreach (ListItem li in cblModules.Items) |
| { |
| var moduleHit = (from a in CoP.Modules where a.ModuleID == Int32.Parse(li.Value) select a.Description).FirstOrDefault(); |
| if (!string.IsNullOrEmpty(moduleHit)) |
| ToolTipify(li, moduleHit); |
| } |
| } |
When the OnSelectedIndexChanged event is fired, LoadTooltips is called at the end to rebuild the Tooltips for the cblModules. Unfortunately, nothing happens. Here is the code I use to build the Tooltips if it helps.
| private void ToolTipify(ListItem li, string description) |
| { |
| ContentPlaceHolder con = (ContentPlaceHolder)Master.Master.FindControl("cphContent2"); |
| ContentPlaceHolder con1 = (ContentPlaceHolder)con.FindControl("cphCCMContent"); |
| RadToolTip tip = new RadToolTip(); |
| li.Attributes.Add("ID", Guid.NewGuid().ToString()); |
| tip.RelativeTo = ToolTipRelativeDisplay.Element; |
| tip.Text = description; |
| tip.TargetControlID = li.Attributes["ID"]; |
| tip.IsClientID = true; |
| con1.Controls.Add(tip); |
| } |
Again, it works on the first time through, when there is no Postback, but when I cause a Postback (clicking on cblModules), the tooltips vanish. If anyone has any ideas or a better solution, I'd be very appreciative.
~Chad Johnson