how to open a new window on click event of node in ASP.Net TreeView control
In my application I need to open a new window f开发者_如何学JAVAorm on click of a node in my TreeView
control.
I'm working with ASP.Net 3.5 / C#.
<asp:TreeNode Value="C1" Text="Master" Expanded="False">
<asp:TreeNode Value="CC1" Text="A"></asp:TreeNode>
</asp:TreeNode>
<asp:TreeNode Value="C2" Text="tempdb" Expanded="False">
<asp:TreeNode Value="CC2" Text="B"></asp:TreeNode>
</asp:TreeNode>
<asp:TreeNode Value="C3" Text="Model" Expanded="False">
<asp:TreeNode Value="CC3" Text="C"></asp:TreeNode>
</asp:TreeNode>
<asp:TreeNode Value="C4" Text="msdb" Expanded="False">
<asp:TreeNode Value="CC4" Text="D"></asp:TreeNode>
</asp:TreeNode>
<asp:TreeNode Value="C5" Text="Projects" Expanded="False">
<asp:TreeNode Value="CC5" Text="E"></asp:TreeNode>
</asp:TreeNode>
<asp:TreeNode Value="C6" Text="Examples" Expanded="False">
<asp:TreeNode Value="CC61" Text="Tables" NavigateUrl="~/ShowPDF.aspx"></asp:TreeNode>
<asp:TreeNode Value="CC62" Text="Views" NavigateUrl="~/Str2Number.aspx"></asp:TreeNode>
<asp:TreeNode Value="CC63" Text="Stored Procedures" NavigateUrl="~/Default.aspx.cs"></asp:TreeNode>
<asp:TreeNode Value="CC64" Text="Triggers" NavigateUrl="~/Default2.aspx"></asp:TreeNode>
<asp:TreeNode Value="CC65" Text="Functions" NavigateUrl="~/Default3.aspx"></asp:TreeNode>
</asp:TreeNode>
<asp:TreeNode Value="C7" Text="AccSys" Expanded="False">
<asp:TreeNode Value="CC7" Text="G"></asp:TreeNode>
</asp:TreeNode>
<asp:TreeNode Value="C8" Text="GarSys" Expanded="False">
<asp:TreeNode Value="CC8" Text="H"></asp:TreeNode>
</asp:TreeNode>
</Nodes>
<HoverNodeStyle Font-Underline="True" />
</asp:TreeView>
TreeNode contains an property called Url. Set the Url appropriately. But you are saying windows form in the question. It is confusing.
If you mean you want the links to open in a new browser window set the target property on the nodes to _blank
.
精彩评论