Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...Open Pdf in new window from datalist in custom moduleOpen Pdf in new window from datalist in custom module
Previous
 
Next
New Post
8/4/2006 6:14 AM
 

Greetings!

I want to open a PDF file in a new window, not in the current page. It was a friend who did this and he is on vacation, so I must figure it out by my own :)

I have the following ascx code:


<asp:DataList id="lstAnexos" Runat="server" EnableViewState="false" BorderStyle="Solid" BorderWidth="1" Width="100%">       <ItemTemplate>
  <!--<asp:HyperLink id="anexoLink_old" runat="server" Visible="true" Target=_blank text='<%# DataBinder.Eval(Container.DataItem,"text") %>' navigateurl='<%# FormatURL(DataBinder.Eval(Container.DataItem,"NavigateUrl")) %>' BorderStyle="NotSet" width=100%/>-->
  <asp:LinkButton ID="anexoLink" CssClass="Normal" Runat="server" OnCommand="lnkDLFile_Command" CommandArgument='<%# DataBinder.Eval(Container.DataItem,"NavigateUrl")%>'><%# DataBinder.Eval(Container.DataItem,"NavigateUrl")%></asp:LinkButton>
 </ItemTemplate>
</asp:DataList>


And in the Vb file:

Private Sub loadAnexos(ByVal objArticle As ArticleInfo)

 Dim sAnexos As String = objArticle.Anexos
 Dim arAnexos As New ArrayList
        Dim item As HyperLink
        Dim sText As String
        Dim sURL As String

        If (Not sAnexos Is Nothing) And (sAnexos <> "") Then
            For Each sURL In sAnexos.Split(",")
                If sURL <> "" Then
                    Dim fc As New DotNetNuke.Services.FileSystem.FileController
             Dim fi As DotNetNuke.Services.FileSystem.FileInfo

                    If sURL.StartsWith("FileID=") Then
                        fi = fc.GetFileById(sURL.Substring(7), PortalId)
                    Else
                        fi = fc.GetFile(sURL, PortalId, "")
                    End If
                    If Not fi Is Nothing Then
                        sText = fi.Folder & fi.FileName
                        item = New HyperLink
                        item.Text = sText
                        item.NavigateUrl = sText
                        arAnexos.Add(item)
                    End If
                End If
            Next
        End If
        lstAnexos.DataSource = arAnexos
        lstAnexos.DataBind()

End Sub

(I don't know why the friend who implement this module put the comments on the hyperlink and used a linkbutton instead!)
I suppose maybe with item.Attributes.Add(..) or javascript window.open I could get something... Concerning the hyperlink, I thought the same and switched comments, but no result! I tried item.Target = "_new" or item.Attributes.Add("target", "_new") and it still opened in the same window. Even with javascript (but here I don't think I did it right)...

I also tried the linkbutton solution, but I cannot seem to enter the lnkDLFile_Command method (I experimented the ItemCommmand which I successfully use in other situations, but I think it requires DataGrid and not DataList. When I changed from Grid to List I got this odd error: The base class includes the field 'attachmentGrid', but its type System.Web.UI.WebControls.DataGrid is not compatible with the type of control System.Web.UI.WebControls.DataList).

The code in lnkDLFile_Command is the following:

'Protected Sub lnkDLFile_Command(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.CommandEventArgs)
            'DownloadFile(e.CommandArgument.ToString())
            'BindFolderTree()
        'End Sub

As you can see it is commented. These methods are used in another module of this DotNetNuke portal and they are working.

I really believe the hyperlink is the better solution (as it is the control created in runtime) so if you can give some help with this I'd really thank you! I've been working on this during the last two days and still no light!

Thanks in advance for your help!
Best regards,

Ricardo Pinto

 
New Post
9/28/2006 7:58 AM
 
Hello!

It has been solved!
Thanks,

Ricardo.
 
Previous
 
Next
HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...Open Pdf in new window from datalist in custom moduleOpen Pdf in new window from datalist in custom module


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out