Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / August 2007

Tip: Looking for answers? Try searching our database.

Treeview - open node in new window

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mel - 20 Aug 2007 20:28 GMT
I have a treeview control that contains a bunch of pdf filenames.  It
would like the files to open in a new window.  Can anyone assist me in
doing that?  The code I currently have is below:

Protected Sub tvDocs_SelectedNodeChanged(ByVal sender As Object, ByVal
e As System.EventArgs) Handles tvDocs.SelectedNodeChanged
   Dim FilNam As String
   FilNam = Mid(tvDocs.SelectedNode.Parent.ValuePath,
InStr(tvDocs.SelectedNode.Parent.ValuePath, "Docs\") + Len("Docs\")) &
"\" & tvDocs.SelectedValue
   If InStr(UCase(tvDocs.SelectedValue), ".PDF") > 0 Then
Response.Redirect("~\1-New-Portal-Tree\" & FilNam)
End Sub

- Mel
(Visual Studio 2005, Asp.net 2.0, Visual Basic)
Ladislav Mrnka - 21 Aug 2007 08:10 GMT
Hi Mel,
do you really need to process node selection on server? TreeNode has
NavigateUrl and Target properties properties. I assume you are binding
TreeView to same data source. You can implement TreeNodeDataBound handler and
set these properties for those nodes. Something like this

 protected void myTreeView_NodeDataBound(Object sender, TreeNodeEventArgs e)
 {
   // Implement some method to check if your node contains pdf document
   if(IsPDF(e.Node.Value))
   {
     // build your url to pdf document
     e.Node.NavigateUrl = BuildMyPath(e.Node.Parent.Value, e.Node.Value);
     e.Target = "_blank";
   }
 }

Regards,
Ladislav

> I have a treeview control that contains a bunch of pdf filenames.  It
> would like the files to open in a new window.  Can anyone assist me in
[quoted text clipped - 12 lines]
> - Mel
> (Visual Studio 2005, Asp.net 2.0, Visual Basic)
Mel - 21 Aug 2007 13:48 GMT
On Aug 21, 2:10 am, Ladislav Mrnka
<LadislavMr...@discussions.microsoft.com> wrote:
> Hi Mel,
> do you really need to process node selection on server? TreeNode has
[quoted text clipped - 32 lines]
> > - Mel
> > (Visual Studio 2005, Asp.net 2.0, Visual Basic)

When the user clicks on a particular .pdf filename I want to open it
for them.  Even though I have the target = "_blank" in the treeview
properties the file opens in the same browser window; I suspect
because I am using Redirect and maybe it's not capable of opening a
new window.  I was just wondering if there was another way to open the
file where it would open in a new window.  If anyone could provide a
detailed example I would really appreciate it.
Mel - 21 Aug 2007 16:44 GMT
On Aug 21, 2:10 am, Ladislav Mrnka
<LadislavMr...@discussions.microsoft.com> wrote:
> Hi Mel,
> do you really need to process node selection on server? TreeNode has
[quoted text clipped - 32 lines]
> > - Mel
> > (Visual Studio 2005, Asp.net 2.0, Visual Basic)

Thank you very much, I fixed it.  I set the Navigate Url to the path
and it worked.  I totally didn't realize that property even
existed ;)  My original code was setting the path upon the
SelectedNodeChanged event.  This way is much better.  I removed all of
the code from the SelectedNodeChanged and now just set the NavigateUrl
when I fill the tree.

Many thanks,
Mel

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.