CodeVerge.Net Beta


   Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: Date Entered: 10/16/2007 1:16:55 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 5 Views: 253 Favorited: 0 Favorite
6 Items, 1 Pages 1 |< << Go >> >|
"vincent9015290
NewsGroup User
How to know the id of a TreeNode in a TreeView?10/16/2007 1:16:55 AM

0

I want to use HoverMenuExtender on a TreeNode of a TreeView, and the HoverMenuExtender need to specify the TargetControlID property. So I need to know the id of every TreeNode in a TreeView. Does anyone know how to do that? Any suggestion is welcome. Thank you for replying.
this.brain=null;
MSN+EMAIL: [email protected]
"Amanda Wang -
NewsGroup User
Re: How to know the id of a TreeNode in a TreeView?10/17/2007 12:27:27 PM

0

Hi,

Base on your description, you want to add the hoverMenu for the treenode, right?

But the treeview is some tables at runtime, you cannot get the treenode's id, but you can do like below:

1. The aspx code:

<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:TreeView ID="TreeView1" runat="server" DataSourceID="SiteMapDataSource1" OnTreeNodeDataBound="TreeView1_TreeNodeDataBound"
            ShowLines="True">
        </asp:TreeView>
        <asp:Panel ID="Panel1" runat="server" Height="50px" Width="125px" Style="display: none">
            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        </asp:Panel>
        <cc1:HoverMenuExtender ID="HoverMenuExtender1" runat="server" BehaviorID="myHMEBID"
            PopupControlID="Panel1" TargetControlID="Button1">
        </cc1:HoverMenuExtender>
        <div style="display: none">
            <asp:Button ID="Button1" runat="server" Text="Button" /></div>

2. the treeview 's TreeNodeDataBound event code:

 int myIndex = 0;

protected void TreeView1_TreeNodeDataBound(object sender, TreeNodeEventArgs e)
    {
        e.Node.Text = "&lt;div id='myDiv" + myIndex.ToString() + "' onmouseover='showHoverMenu(\"myDiv" + (myIndex++).ToString() + "\")' onmouseout='hideHoverMenu()'>" + e.Node.Text + "&lt;/div>";
    }

3. the javascript:

 <script language="javascript" type="text/javascript">    
        var activeDivID="";
        function pageLoad(){
           $find("myHMEBID").add_shown(onHoverMenuShown11);
        }
        function onHoverMenuShown11(){
          var activeDivLocation = $common.getLocation($get(activeDivID));
          $common.setLocation($find("myHMEBID").get_popupElement(),new Sys.UI.Point(activeDivLocation.x + $get(activeDivID).offsetWidth,activeDivLocation.y));
          $get("<%=TextBox1.ClientID %>").value = $get(activeDivID).innerText;
        }
        function showHoverMenu(divID){
           activeDivID = divID;
           $find("myHMEBID")._onUnhover();   
           $find("myHMEBID")._onHover();
        }
        function hideHoverMenu(divID){
           $get("<%=Panel1.ClientID %>").style.display= "none";
        }

    </script>
 

Hope it helps.


Please remember to mark the replies as answers if they help and unmark them if they provide no help.


Yours sincerely,
Amanda Wang
Microsoft Online Community Support
"vincent9015290
NewsGroup User
Re: How to know the id of a TreeNode in a TreeView?10/19/2007 9:42:06 AM

1

Wow! That is so cool!

Thank you very much.


this.brain=null;
MSN+EMAIL: [email protected]
"a.stalmokas" <
NewsGroup User
Re: Amanda's example not working for me10/22/2007 7:36:19 AM

0

Hi, i'd like to get treeView and HoweMenuExtender working together, too.

I tried to do a test page with Amanda's code and I'm getting TAGGY (instead of clear text) tree nodes in UI:

&lt;/div>" src="...">
<div id='myDiv0' onmouseover='showHoverMenu("myDiv0")' onmouseout='hideHoverMenu()'></div>        
<div id='myDiv1' onmouseover='showHoverMenu("myDiv1")' onmouseout='hideHoverMenu()'>Gauti prane?imai</div>        
<div id='myDiv2' onmouseover='showHoverMenu("myDiv2")' onmouseout='hideHoverMenu()'>Atrinkti prane?imai</div>

and an ERROR image in a leftbottom conner  of a browser with a error message: "Object doesn't support this property or method" with a line number, which corresponds to a script  $find("myHMEBID").add_shown(onHoverMenuShown11);

WHAT I'm doing wrong? Do I missed any declaration or something else? 

THANKS in advanse.

"Amanda Wang -
NewsGroup User
Re: Amanda's example not working for me10/22/2007 8:13:15 AM

0

Hi

if you want to use $find("myHMEBID").add_shown(onHoverMenuShown11);  the ScriptManager is prerequisite.

That is to say, there must be ScriptManager on the page.

<asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>

 or else, you should use the method: document.getelemetbyid.

Hope it helps.


Please remember to mark the replies as answers if they help and unmark them if they provide no help.


Yours sincerely,
Amanda Wang
Microsoft Online Community Support
"lenchase" <>
NewsGroup User
Re: Amanda's example not working for me5/5/2008 12:07:41 PM

0

Hi:

I am trying to use your solution and get te following error!

Any help would be appreciated.

Thanks Len

The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

Any suggestions I am in the 3.5 framework wih vb.

<head runat="server">

<title>Untitled Page</title>

<script language="javascript" type="text/javascript">

var activeDivID="";

function pageLoad(){

alert("here");

$find("myHMEBID").add_shown(onHoverMenuShown11);

}

function onHoverMenuShown11(){

var activeDivLocation = $common.getLocation($get(activeDivID));

$common.setLocation($find("myHMEBID").get_popupElement(),new Sys.UI.Point(activeDivLocation.x + $get(activeDivID).offsetWidth,activeDivLocation.y));$get("<%=TextBox1.ClientID %>").value = $get(activeDivID).innerText;

}

function showHoverMenu(divID){

activeDivID = divID;

$find("myHMEBID")._onUnhover();

$find("myHMEBID")._onHover();

}

function hideHoverMenu(divID){$get("<%=Panel1.ClientID %>").style.display= "none";

}

</script>

</head>

<body>

<form id="form1" runat="server">

<div>

 

<asp:ScriptManager ID="ScriptManager1" runat="server">

</asp:ScriptManager>

<asp:TreeView ID="TreeView1" runat="server" DataSourceID="SiteMapDataSource1" OnTreeNodeDataBound="TreeView1_TreeNodeDataBound"

ShowLines="True">

</asp:TreeView>

<asp:Panel ID="Panel1" runat="server" Height="50px" Width="125px" Style="display: none">

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

</asp:Panel>

<ajaxToolkit:HoverMenuExtender ID="HoverMenuExtender1" runat="server" BehaviorID="myHMEBID"

PopupControlID="Panel1" TargetControlID="Button1">

</ajaxToolkit:HoverMenuExtender>

<div style="display: none">

<asp:Button ID="Button1" runat="server" Text="Button" /></div>

 

</div>

</form></body>

vb code

Partial Class aaaTestPages_treeviewHover

Inherits System.Web.UI.Page

Dim myindex As Integer = 0

Protected Sub TreeView1_TreeNodeDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.TreeNodeEventArgs) Handles TreeView1.TreeNodeDataBound

e.Node.Text = "&lt;div id='myDiv" + myindex.ToString() & "'" _

& " onmouseover='showHoverMenu('myDiv' & (myIndex++).ToString()" & "')" & _

" onmouseout='hideHoverMenu()'>" & e.Node.Text & "&lt;/div>"

End Sub

End Class


 

6 Items, 1 Pages 1 |< << Go >> >|


Free Download:













treeview.checknodes.count in javascript?

data centric web application layout templates

masterpages, folders and images

need help for treeview control

problem with master/child page displaying edge line

simple doubt on contentplaceholder

master pages with firefox not working

server side code of the content page

nesting mapsite providers, and logout implimentation

treeview menu looks wrong once uploaded to internet

user specific themes?

adding a style to a button tag

beta2 wizard validator problem

accessing a method inside a master page

menu control rendering differently based on browser

the problem about applying skin to usercontrol

sitemaps and security trimming

problem in displaying images ?

encryp & decrypt querystring

treeview problem (2.0b)

web.config themepreference

me.placeholder1.page.request.form.set("textbox", "test")

how to refresh datalist control in master page from nested page

tree view in update panel

some questionable remarks in the sitemappath document

need help with including a link button on a master page.

using findcontrol with a page in a master page.

remove arrow from menu

menu control running javascript problem

treeview

masterpage in database??

highlight root node on menu control when child pages are loaded.

menu control question about linking to another website?

controlling the refreshing of controls

hi, please help!!!

body background not loaded

masterpage page_load or init events execute more than once ?

dynamically adding menu items to a menu control

how to leave the white spaces at left and right of the web without affecting the contents in the middle?

question on master pages

how to turn root node and more in when using as bread crumbs?

how to create msdn likde splitter in masterpage

call functions many times in my pages!!!

treeview + sitemap +selectaction fails

web.sitemap overwrite programmatically

master page method: code-behind for content page

treeview, how to make leaf node looks like parent node?

overriding cursor style in menu items

problem with user control

background-image in master page

   
  Privacy | Contact Us
All Times Are GMT