i have a treeview control which binds all folders and files in my application like below
<asp:TreeView ID="tvFolders" runat="server">
<HoverNodeStyle Font-Underline="false" ForeColor="#5555DD" />
<NodeStyle Font-Names="Verdana" Font-Size="8pt" ForeColor="Black" HorizontalPadding="5px"
ImageUrl="~/images/childfolder.png" NodeSpacing="0px" VerticalPadding="0px" />
<ParentNodeStyle Font-Bold="False" ImageUrl="~/images/childfolder.png" />
<SelectedNodeStyle Font-Underline="True" ForeColor="#5555DD" HorizontalPadding="0px"
VerticalPadding="0px" />
<LeafNodeStyle />
</asp:TreeView>
i need two buttons at each leafnode as download,delete. if i click those buttons respective actions should done for respective node(file).
for this i have binded my treeview like below
foreach (string folder in Directory.GetDirectories(Server.MapPath("~/")))
{
string filename = Path.GetFileName(folder);
if (filename.StartsWith("FY"))
{
TreeNode tn = new TreeNode();
tn.Text = filename;
tn.Target = "_blank";
tvFolders.Nodes.Add(tn);
foreach (string innerfolder in Directory.GetDirectories(folder + "/"))
{
TreeNode intn = new TreeNode();
intn.Text = Path.GetFileName(innerfolder);
intn.Target = "_blank";
tn.ChildNodes.Add(intn);
DirectoryInfo directory = new DirectoryInfo(innerfolder);
FileInfo[] files = directory.GetFiles("*");
foreach (FileInfo file in files)
{
StringBuilder nodeText = new StringBuilder();
nodeText.Append(@"<table border="" 0="" cellpadding="" cellspacing=""><tr><td>");
nodeText.Append(@"<a style="" href="#" hold=" /> nodeText.Append(@"> ").Append(file.Name).Append("</a>");
nodeText.Append(@"</td><td>");
nodeText.Append(@"</td><td>");
nodeText.Append(@" <a href="#"><input id='filedownload' title='Download' type='image' height='10px' height='10px' src='images/download.png' /></a> ");
nodeText.Append(@" <a href="#"><input id='filedelete' type='image' title='Delete' height='10px' height='10px' ;' src='images/delete_node.png' /></a>");
nodeText.Append(@"</td></tr></table><a href="#">");
TreeNode file1 = new TreeNode();
file1.Text = nodeText.ToString();
file1.Value = "File";
file1.Target = "_blank";
if (file.Extension == ".doc" || file.Extension == ".docx")
file1.ImageUrl = "~/images/wordicon.png";
else if (file.Extension == ".pdf")
file1.ImageUrl = "~/images/pdficon.png";
else if (file.Extension == ".xls" || file.Extension == ".xlsx")
file1.ImageUrl = "~/images/excelicon.png";
else
file1.ImageUrl = "~/images/fileimg.png";
intn.ChildNodes.Add(file1);
}
}
}
}
so now i am getting two input buttons for each leaf node.
the problem is i m unable to get postback event for that leafnode click. i tryed to do in javascript __dopostback but my page is having update panel, it may be effecting not to postback.
i dont knw.
How to get leaf node click event in code behind.
i also tryd writing window.open(respective file path); in download button. it also not working
pls help.
thanks advance.