0
我正在使用ASP.Net TreeView控件,並使用C#動態加載Treeview;ASP.Net Treeview控件不在Web服務器上的iFrame中顯示文檔
利用iFrame,文檔顯示在iFrame中 - 基於TreeNode選擇;
在我的電腦上一切正常,並且文檔從網絡中的公共驅動器正確顯示;
但是,在將ASP.Net Web應用程序發佈到Web服務器後,遇到了問題;
在Web服務器上重新創建帶有文檔的公共文件夾 - 我的期望是該過程將以與我的PC上的過程相同的方式工作;
ASP.Net TreeView的人口工作正常;但是,如果選擇了TreeView節點 - 從TreeView中選擇的文檔不會顯示;
代碼片段如下;預先感謝任何見解!最好的問候 - 羅布
private void BuildTree()
{
DirectoryInfo rootDir = new DirectoryInfo(Server.MapPath("./Customers/Associated Food Stores/"));
TreeNode rootNode = new TreeNode(rootDir.Name, rootDir.FullName);
TreeView1.Nodes.Add(rootNode);
//begin recursively traversing the directory structure
TraverseTree(rootDir, rootNode);
}
private void TraverseTree(DirectoryInfo currentDir, TreeNode currentNode)
{
//loop through each sub-directory in the current one
foreach (DirectoryInfo dir in currentDir.GetDirectories())
{
//create node and add to the tree view
TreeNode node = new TreeNode(dir.Name, dir.FullName);
currentNode.ChildNodes.Add(node);
foreach (System.IO.FileInfo f in dir.GetFiles("*.*"))
{
TreeNode nodeFile = new TreeNode(f.Name, f.FullName);
currentNode.ChildNodes.Add(nodeFile);
}
//recursively call same method to go down the next level of the tree
TraverseTree(dir, node);
}
TreeView1.CollapseAll();
//TreeView1.NodeIndent = 15;
}
protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
{
//this.Label1.Text = "Selected Node changed to: " + this.TreeView1.SelectedNode.Text;
var src = this.TreeView1.SelectedValue;
if (this.TreeView1.SelectedValue.EndsWith("pdf"))
{
myPDF.Attributes["src"] = src;
myPDF.Visible = true;
btnClose.Visible = true;
}
}