Hi Guys,
After sorting out my recent problems getting radtooltip to work inside a datalist I found out i can't use Load on Demand with a tootip, only with a tooltip manager so I have had to rewrite it all to get it working. However I am having lots of problems.
First of all here is my code.
1 | <%@ Page Language="VB" MasterPageFile="Master.master" %> |
2 | <%@ MasterType virtualPath="Master.master"%> |
3 | |
4 | <%@ Import Namespace="System.Configuration.ConfigurationManager" %> |
5 | <%@ Import Namespace="System.Data" %> |
6 | <%@ Import Namespace="System.Data.SqlClient" %> |
7 | <%@ Import Namespace="System.collections.Generic" %> |
8 | <%@ Import Namespace="Tvi" %> |
9 | |
10 | <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> |
11 | |
12 | |
13 | |
14 | <script runat="server"> |
15 | |
16 | Dim Reader As SqlDataReader |
17 | Dim Files As String = AppSettings("files_url") |
18 | |
19 | Sub Page_Load() |
20 | |
21 | MyRepeater.DataSource = Database.getDataReader("SELECT TOP 10 Caption, Thumbnail FROM Photos") |
22 | MyRepeater.DataBind() |
23 | |
24 | End Sub |
25 | |
26 | |
27 | Sub MyRepeaterBound(ByVal sender As Object, ByVal e As RepeaterItemEventArgs) |
28 | |
29 | If e.Item.ItemType = ListItemType.AlternatingItem OrElse e.Item.ItemType = ListItemType.Item Then |
30 | |
31 | Dim TempImage As Image = DirectCast(e.Item.FindControl("MyImage"), Image) |
32 | |
33 | Dim ClientID As String = TempImage.ClientID |
34 | |
35 | CommentToolTip.TargetControls.Add(ClientID, True) |
36 | |
37 | End If |
38 | |
39 | End Sub |
40 | |
41 | |
42 | Protected Sub OnAjaxUpdate(ByVal sender As Object, ByVal args As ToolTipUpdateEventArgs) |
43 | Dim elementID As String = args.TargetControlID |
44 | 'Add content when necessary |
45 | args.UpdatePanel.ContentTemplateContainer.Controls.Add(New HtmlGenericControl("HR")) |
46 | End Sub |
47 | |
48 | </script> |
49 | |
50 | <asp:Content ID="Content" ContentPlaceHolderID="Content" runat="server"> |
51 | <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> |
52 | |
53 | <asp:UpdatePanel ID="UpdatePanel1" runat="server"> |
54 | <ContentTemplate> |
55 | |
56 | |
57 | <asp:repeater runat="server" id="MyRepeater" onitemdatabound="MyRepeaterBound"> |
58 | <itemtemplate> |
59 | <asp:image runat="server" id="MyImage" imageurl='<%# Files + DataBinder.Eval(Container.DataItem, "Thumbnail")%>'/> |
60 | </itemtemplate> |
61 | </asp:repeater> |
62 | |
63 | |
64 | </ContentTemplate> |
65 | </asp:UpdatePanel> |
66 | |
67 | <telerik:radtooltipmanager |
68 | runat="server" |
69 | id="CommentToolTip" |
70 | ManualClose="true" |
71 | Sticky="true" |
72 | Title="Hello" |
73 | Skin="Web20" |
74 | Width="350px" |
75 | Height="250px" |
76 | Position="MiddleRight" |
77 | OffsetX="6" |
78 | Animation="Fade" |
79 | OnAjaxUpdate="OnAjaxUpdate"> |
80 | </telerik:radtooltipmanager> |
81 | |
82 | |
83 | |
84 | </asp:Content> |
I should explain that line 21 uses a function of our own data layer. My problems are as follows....
1) When i remove the
OnAjaxUpdate="OnAjaxUpdate" the page works. It shows a blank tooltip when you click on each photo. However, when I add the OnAjaxUpdate back in it stops working. The tooltips show for half a second then disappear again.
It does this in Firefox and IE and does it when i take all of the code out of the onajaxupdate sub too so the problem doesn't seem to be with the contents of that sub.
2) Because I am now using a radtooltipmanager rather than a radtooltip inside the datalist i have no idea how to change the title of the tooltip to the "Caption" I am getting from the database. When I was using a tooltip in the datalist I just did this...
Title='<%# DataBinder.Eval(Container.DataItem, "Caption") %>'
3) I copied the OnAjaxUpdate Sub from a telerik example but have no idea what it is doing. WHy is ElementID declared and then not used ? And what is args.UpdatePanel.ContentTemplateContainer.Controls.Add ? Does the Tooltip have it's own updatepanel inside it ?
Any help would be really appreciated as I just don't understand the online demos or the documentation. A very simple example would be useful to many others I'd guess.
Thanks, Jon