Home - Forums-.NET - FlyTreeView (ASP.NET) - Use FlyTreeView user control twice in one aspx page

FlyTreeView (ASP.NET)

Technical support and KB related to the FlyTreeView control

This forum related to following products: FlyTreeView for ASP.NET

Use FlyTreeView user control twice in one aspx page
Link Posted: 02-Aug-2011 08:46
Hello, We purchased this control last week and trying to integrate this control in our asp.net project (framework 2.0). So we have made FlyTreeView as user control and trying to use this across all the web pages. But in some pages, we have to display FlyTreeView control two times, so we are having difficulties calling that control twice. See the following sample code from .aspx page. Clicking on any dropdown icon will show the treeview control in 1st control
DDl1 DDl2
Could you please advise how to add FlyTreeView control twice in the same page?
Link Posted: 02-Aug-2011 08:53
There should not be any problems with adding multiple FlyTreeView controls on the same page.
And one of the control demos contains two treeviews.
What kind of problems do you experience?
How do you integrate it into dropdown?
Link Posted: 02-Aug-2011 09:04
here is the code for .ascx page [code] var treeviewID = ''; function toggleTreeView(ev, hide) { var ddTreeView = document.getElementById("ddTreeView"); ddTreeView.style.display = (hide == null && ddTreeView.style.display == "none") || hide == false ? "" : "none"; // this is a global function of FlyTreeView runtime var rect = ninerays_getElementRect(document.getElementById("tvInput")); ddTreeView.style.top = (rect.bottom - 1) + "px"; ddTreeView.style.left = rect.left + "px"; ev = ev ? ev : window.event; if (ev) ev.cancelBubble = true; } function setInputText() { var treeview = CFlyTreeView.getInstanceById(treeviewID); var selectedNode = treeview.getSelectedNode(); var text = selectedNode ? selectedNode.getText() : ""; var tvInput = document.getElementById("tvInput"); tvInput.value = text; } function treeview_OnSelectedNodeChanged(treeview, oldNode, newNode) { setInputText(); toggleTreeView(); } function treeview_OnInitialized(treeview) { setInputText(); document.onmousedown = document_onmousedown } function document_onmousedown(ev) { // hide treeview when mousedown event // comes from any element except treeview child elements var eventSrc = ev && ev.target ? ev.target : event.srcElement; var treeviewElement = document.getElementById(treeviewID); while (eventSrc) { if (eventSrc == treeviewElement) return; eventSrc = eventSrc.parentNode; } toggleTreeView(ev, true); } [/code] here is the code for .aspx page [code]
DDl1 --%> DDl2 --%>
[/code] Am i doing anything wrong>
Link Posted: 02-Aug-2011 09:11
Sure, it looks like you are using a constant value for treeview identifier ddTreeView.
This makes JavaScript be always executed against a single treeview on your page.

You should probably use  instead of ddTreeView.
Link Posted: 02-Aug-2011 10:20
it didn't work, because ddtreeview is client side control and the clientid will be always same. This is same for tvInput textbox also.

Could you please advise?