Hi,
I have a problem with a tooltipmanager which is quite complicated but I will try to explain......
My page contains a datalist of Photos. Under each photo is a textbox which is initially hidden (visibility=false), there is also a button to open the textbox and a span which has Rad:Tooltips bound to it.
My problem is that the Tooltips only show when the page is initially loaded. If I initiate a callback they stop working, unless I reload the photos from the database and Databind the Datalist again.
I really can't rebind the datalist on every callback as it clears the contents on my textboxes and makes them go invisible again.
(Of course, if anybody knows how I can rebind the photos without clearing the textboxes and making them invisible that would also fix the problem I suppose)
I have provided some code below which is as simple as I can make it. You can see it running at the following URL - Click here
I have a problem with a tooltipmanager which is quite complicated but I will try to explain......
My page contains a datalist of Photos. Under each photo is a textbox which is initially hidden (visibility=false), there is also a button to open the textbox and a span which has Rad:Tooltips bound to it.
My problem is that the Tooltips only show when the page is initially loaded. If I initiate a callback they stop working, unless I reload the photos from the database and Databind the Datalist again.
I really can't rebind the datalist on every callback as it clears the contents on my textboxes and makes them go invisible again.
(Of course, if anybody knows how I can rebind the photos without clearing the textboxes and making them invisible that would also fix the problem I suppose)
I have provided some code below which is as simple as I can make it. You can see it running at the following URL - Click here
| <%@ Page Language="VB" %> | |
| <%@ Import Namespace="System.Configuration.ConfigurationManager" %> | |
| <%@ Import Namespace="System.Data" %> | |
| <%@ Import Namespace="System.Data.SqlClient" %> | |
| <%@ Import Namespace="Tvi" %> | |
| <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> | |
| <%@ register src="OtherControls/PhotoComments.ascx" tagname="PhotoComments" tagprefix="MMALO" %> | |
| <script runat="server"> | |
| Dim Reader As SqlDataReader | |
| Dim Files As String = AppSettings("files_url") | |
| Sub Page_Load() | |
| If Not Page.IsPostBack Then | |
| BindPhotos(Request.QueryString("ID")) | |
| End If | |
| End Sub | |
| Sub BindPhotos(ByVal GalleryID As Integer) | |
| Dim PhotoSQL As String = "SELECT P.ID AS PhotoID, p.Thumbnail AS Thumbnail, p.Photo AS Photo, P.Caption AS Caption, P.TagCount AS TagCount " | |
| PhotoSQL += "FROM Photos P " | |
| PhotoSQL += "INNER JOIN PhotoGalleries PG ON P.PhotoGalleryID = PG.ID " | |
| PhotoSQL += "LEFT OUTER JOIN PhotoComments PC ON PPC.PhotoID = P.ID " | |
| PhotoSQL += "WHERE P.Status='Live' AND PG.ID='" + GalleryID.ToString + "';" | |
| DL_Photos.DataSource = Database.getDataReader(PhotoSQL) | |
| DL_Photos.DataBind() | |
| End Sub | |
| Sub Photos_Bound(ByVal obj As Object, ByVal e As DataListItemEventArgs) | |
| If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then | |
| ''''''''''''''''''''''''''''''''''''''''''''''''''''''''' | |
| ' Add tooltips | |
| ''''''''''''''''''''''''''''''''''''''''''''''''''''''''' | |
| Dim CommentLabel As HtmlGenericControl = DirectCast(e.Item.FindControl("lbViewComments"), HtmlGenericControl) | |
| CommentLabel.ID = e.Item.DataItem("PhotoID").ToString | |
| CommentToolTip.TargetControls.Add(CommentLabel.ClientID, True) | |
| ''''''''''''''''''''''''''''''''''''''''''''''''''''''''' | |
| ' Hide Comment Boxes | |
| ''''''''''''''''''''''''''''''''''''''''''''''''''''''''' | |
| CType(e.Item.FindControl("CommentBoxDiv"), HtmlGenericControl).Visible = "False" | |
| End If | |
| End Sub | |
| Protected Sub OnAjaxUpdate(ByVal sender As Object, ByVal args As ToolTipUpdateEventArgs) | |
| Dim index As Integer = args.TargetControlID.LastIndexOf("_") | |
| Dim elementID As String = args.TargetControlID.Substring(index + 1) | |
| Dim PhotoComments As New PhotoComments | |
| args.UpdatePanel.ContentTemplateContainer.Controls.Add(PhotoComments) | |
| Dim Comments As PhotoComments = DirectCast(PhotoComments, PhotoComments) | |
| Comments.PhotoID = elementID | |
| End Sub | |
| Sub PhotoCommand(ByVal obj As Object, ByVal E As DataListCommandEventArgs) | |
| Dim Command As String = E.CommandName | |
| Dim Argument As String = E.CommandArgument | |
| Select Case Command | |
| Case "OpenCommentBox" | |
| CType(E.Item.FindControl("CommentBoxDiv"), HtmlGenericControl).Visible = True | |
| Case "CancelComment" | |
| CType(E.Item.FindControl("CommentBoxDiv"), HtmlGenericControl).Visible = False | |
| Case "AddComment" | |
| ' --->>> Code for adding the comment to the DB goes here. | |
| CType(E.Item.FindControl("CommentBox"), TextBox).Text = "" | |
| CType(E.Item.FindControl("CommentBoxDiv"), HtmlGenericControl).Visible = False | |
| End Select | |
| End Sub | |
| Sub InitiateCallback(ByVal obj As Object, ByVal E As EventArgs) | |
| BindPhotos(Request.QueryString("ID")) | |
| End Sub | |
| </script> | |
| <html xmlns="http://www.w3.org/1999/xhtml" > | |
| <head> | |
| </head> | |
| <body> | |
| <form id="form1" runat="server"> | |
| <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" /> | |
| <asp:UpdatePanel ID="PhotoPanel" runat="server"> | |
| <ContentTemplate> | |
| <asp:LinkButton ID="Initiate" runat="server" OnClick="InitiateCallback" Text="Click here to initiate a callback and rebind the datalist" /> | |
| <br /> | |
| <br /> | |
| <asp:DataList CellSpacing="8" ID="DL_Photos" OnItemCommand="PhotoCommand" OnItemDataBound="Photos_Bound" runat="server" RepeatColumns="3" RepeatDirection="Horizontal" CssClass="GalleryTable"> | |
| <ItemStyle CssClass="GalleryPhoto" /> | |
| <ItemTemplate> | |
| <img src="<%# Files + DataBinder.Eval(Container.DataItem, "Thumbnail")%>" /> | |
| <div> | |
| <asp:LinkButton ID="OpenCommentBoxButton" CommandName="OpenCommentBox" runat="server" Text="Add Comment"/> | |
| <span ID="lbViewComments" style="cursor:pointer;" runat="server">10 Comments</b></span> | |
| </div> | |
| <div id="CommentBoxDiv" runat="server"> | |
| <asp:textbox ID="CommentBox" runat="server" TextMode="MultiLine" Width="180" height="82" CssClass="CommentBox" /> | |
| <br /> | |
| <asp:LinkButton ID="CommentAddButton" runat="Server" CommandName="AddComment" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "PhotoID") %>' ><IMG SRC="i/CommentButtonAdd.jpg" /></asp:LinkButton> <asp:LinkButton ID="CommentCancelButton" CommandName="CancelComment" runat="Server"><IMG SRC="i/CommentButtonCancel.jpg" /></asp:LinkButton> | |
| </div> | |
| </div> | |
| </ItemTemplate> | |
| </asp:DataList> | |
| </ContentTemplate> | |
| </asp:UpdatePanel> | |
| <telerik:radtooltipmanager | |
| runat="server" | |
| id="CommentToolTip" | |
| ManualClose="true" | |
| showevent="Onclick" | |
| Sticky="true" | |
| Skin="Web20" | |
| Width="350px" | |
| Height="250px" | |
| Position="MiddleRight" | |
| OffsetX="6" | |
| onajaxupdate="onajaxupdate" > | |
| </telerik:radtooltipmanager> | |
| </form> | |
| </body> | |
| </html> |