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

how to display file content with tooltip

5 Answers 244 Views
ToolTip
This is a migrated thread and some comments may be shown as answers.
HL
Top achievements
Rank 1
HL asked on 21 Jun 2011, 11:30 PM
Hi all:
    I try to display the file ( txt, image , PDF , word..etc format) using tooltip. ( just like the sameple
http://demos.telerik.com/aspnet-ajax/tooltip/examples/targetcontrolsandajax/defaultvb.aspx)

the issue is that when I mouse over the record, I got the following error : "RadTootipManager response error. ...the message received from server could not parsed..."

what I did is to read the files then use the response.write to generate the file content.please see code below:

'on parent page which has tooltip with it
  
    Private Sub UpdateToolTip(ByVal elementID As String, ByVal panel As UpdatePanel)
        Dim ctrl As Control = Page.LoadControl("WidgetControls/WidgetSupportDocument.ascx")
        panel.ContentTemplateContainer.Controls.Add(ctrl)
        Dim details As WidgetSupportDocument = DirectCast(ctrl, WidgetSupportDocument)
        details.SupportDocumentID = elementID
        details.DisplayData()
  
    End Sub


on WidgetSupportDocument.ascx control:
Public Sub DisplayData()
      Dim dsData As DataSet
      Dim strFileName As String
      Dim byteData() As Byte
      Dim strDocumentType As String
      Dim arrSplit() As String
      'load data from database
      dsData = LoadData(Me.SupportDocumentID)
      byteData = CType(dsData.Tables(0).Rows(0).Item("FileContent"), Byte())
      arrSplit = Split(dsData.Tables(0).Rows(0).Item("Filename").ToString, ".")
      intLastValue = arrSplit.Length
      strDocumentType = arrSplit(intLastValue - 1)
      SetControlData(strDocumentType, byteData)
  End Sub
  Private Sub SetControlData(ByVal strDocumentType As String, ByVal byteView() As Byte, Optional ByVal strFileName As String = "")
      Dim strContentType As String = String.Empty
      Select Case UCase(strDocumentType)
          Case "HTML", "HTM"
              strContentType = "text/HTML"
          Case "BMP"
              strContentType = "image/BMP"
          Case "JPG"
              strContentType = "image/JPEG"
          Case "GIF"
              strContentType = "image/GIF"
          Case "PDF"
              strContentType = "application/pdf"
          Case "XLS"
              strContentType = "application/vnd.ms-excel"
          Case "DOC"
              strContentType = "application/msword"
          Case "TXT", "LOG"
              ' .txt file (such as a report tab delimited export) should open inline rather then directly in the browser 
              If strFileName = "" Then
                  strFileName = "ViewDocument.txt"
              End If
              With Response
                  .ClearContent()
                  .ClearHeaders()
                  strContentType = "text/unknown"
                  .AddHeader("Content-Length", CType(byteView.Length, String))
                  .AddHeader("Content-Disposition", "inline; filename=" & strFileName)
              End With
          Case Else
      End Select
      If strContentType.Length > 0 Then
          With Response
              .Clear()
              .ContentType = strContentType
              .BinaryWrite(byteView)
              .Flush()
          End With
      Else
          Response.Write("<font color='red'>The selected attachement cannot be displayed. </font>")
                End If
  End Sub


Thanks
Helena

5 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 22 Jun 2011, 03:34 PM
Hi Helena,

  Generally when using AJAX also using the Response object is prone to generating this error, as it modifies the response sent from the server, which makes it have an unexpected format for the script that is to parse it. You can find a simplified example of this behavior in the following blog post: http://encosia.com/the-easiest-way-to-break-aspnet-ajax-pages/. You can find more information on the matter in the web if you like.

What I would recommend is that you use a simple label or literal control to populate the text you wish to write via its Text property. You can find a simple demonstration page based on your code attached as an example.


Greetings,
Marin
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
HL
Top achievements
Rank 1
answered on 23 Jun 2011, 09:01 PM

Hi Martin:

  Thanks for your help. I checked the web site and figured out how to resolve reposonse.write with updatePanel issue. Now I can click the button then display the image/doc/txt by open the new pop up window where the click button is inside the updatepanel, Can you please tell me how it is possible to attach this aspx page with RadTooltip ? I am not sure how I can write all the attached files to the liter control as you suggested before. What I want to do is the file automatically display when I mouse over the fileName

 

Thanks

Helena

 

0
Marin Bratanov
Telerik team
answered on 24 Jun 2011, 12:19 PM
Hi Helena,

The RadToolTip or RadToolTipManagers generally do not support adding entire pages inside. You could try adding an iframe and loading your page inside this iframe, though, but I cannot guarantee that this approach will work correctly in all cases, since iframes themselves are prone to causing issues.

Another possible approach is to manually attach to the mouseover event of the target elements and show a RadWindow - you can set its NavigateUrl to the page where you output the file.

I hope this helps you advance in your project. If you are having any issues stemming from our controls do not hesitate to contact us again.


All the best,
Marin
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
HL
Top achievements
Rank 1
answered on 24 Jun 2011, 06:41 PM
Hi Martin:
   Thanks for your suggestion. I use the Radwindow now and it works even It is not as good as RadToolTip. Now the issue is that how I can get rid of lots of icon on the top of RadWindow? example: Pin, Reload image ...etc. I tried to set up Behaviors but it won't work

Behaviors

="Close, Move, Resize,Maximize"

Thanks
Helena

 

0
Marin Bratanov
Telerik team
answered on 28 Jun 2011, 08:30 AM
Hello Helena,

The Behaviors property lists the options (icons) that will be available. Thus if you want to have only the close button you would need to define it like so:
Behaviors="Close"



Regards,
Marin
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
ToolTip
Asked by
HL
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
HL
Top achievements
Rank 1
Share this question
or