Hi All
I am using Visual Studio 2008/C#.
The page consists of an ASP:Treeview. The treenodes are populated with
the contents of a selected directory consisting of a number
of .doc/.xls/.txt/.pdf documents. The user can then select a document
(by clicking) and the document will open up in the browser. This works
well in IE 7.0. In IE 8.0 and IE 9.0 The directory is read and the
nodes populated correctly but the document links will not work at all.
The document links do not work in Mozilla either.
Can anyone shine a light on the problem ? I would appreciate any input
I can get.
Many thanks in advance
Regards
Iain Wilson
Source Code
------------------
<asp:TreeView ID="TreeView1"
runat="server"
Width="971px"
AutoGenerateDataBindings="true"
ExpandDepth=0
NodeIndent="20"
OnTreeNodePopulate="Treeview1_TreeNodePopulate"
align = "left">
<NodeStyle Font-Names="Arial"
Font-Size="8pt"
ForeColor="DarkBlue"
HorizontalPadding="5"/>
<RootNodeStyle Font-Bold="True"
Font-Size="11pt"/>
<Nodes>
<asp:TreeNode Value="\\Dun-Server3\All_Work_Instructions"
Text="Work Instructions"
PopulateOnDemand="true"
SelectAction="Select"
NavigateUrl="" >
</asp:TreeNode>
</Nodes>
</asp:TreeView>
private void LoadChildNode(TreeNode node)
{
string theDirectory = node.Value;
DirectoryInfo directory;
directory = new DirectoryInfo(theDirectory);
foreach (DirectoryInfo sub in directory.GetDirectories())
{
TreeNode subNode = new TreeNode(sub.Name);
subNode.Value = sub.FullName;
lbl_Error.Text = lbl_Error.Text + subNode.Value + "<br>";
try
{
if (sub.GetDirectories().Length > 0 ||
sub.GetFiles().Length > 0)
{
subNode.SelectAction =
TreeNodeSelectAction.SelectExpand;
subNode.PopulateOnDemand = true;
subNode.NavigateUrl = "#";
}
}
catch (Exception ex)
{
lbl_Error.Text = "Message : " + ex.Message + "<br>";
lbl_Error.Text = lbl_Error.Text + "Source : " + ex.Source
+ "<br>";
lbl_Error.Text = lbl_Error.Text + "TargetSite : " +
ex.TargetSite.Name + "<br>";
lbl_Error.Text = lbl_Error.Text + "StackTrace : " +
ex.StackTrace;
}
subNode.ImageUrl = "~/Images/Folder.jpg";
node.ChildNodes.Add(subNode);
}
foreach (FileInfo fi in directory.GetFiles())
{
string nodeFullName = "";
if (Request.Browser.Browser != "IE")
{
nodeFullName = "<a href='file:" +
Server.MapPath(fi.FullName) + "'>" + fi.Name + "</a>";
}
else
{
nodeFullName = "<a href='" + fi.FullName + "'>" + fi.Name
+ "</a>";
}
lbl_Error.Text = nodeFullName + "<br>";
TreeNode subNode = new TreeNode(nodeFullName);
subNode.ImageUrl = "~/Images/Document.jpg";
node.ChildNodes.Add(subNode);
}
}
protected void Treeview1_TreeNodePopulate(object sender,
TreeNodeEventArgs e)
{
try
{
if (e.Node.ChildNodes.Count == 0)
{
lbl_Error.Text = "Building File List" + "<br />";
LoadChildNode(e.Node);
}
}
catch (Exception ex)
{
lbl_Error.Text = "Message : " + ex.Message + "<br>";
lbl_Error.Text = lbl_Error.Text + "Source : " + ex.Source +
"<br>";
lbl_Error.Text = lbl_Error.Text + "TargetSite : " +
ex.TargetSite.Name + "<br>";
lbl_Error.Text = lbl_Error.Text + "StackTrace : " +
ex.StackTrace;
}
}
--
You received this message because you are subscribed to the Google
Groups "DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML
Web Services,.NET Remoting" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/dotnetdevelopment?hl=en?hl=en
or visit the group website at http://megasolutions.net