.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

Showing Popup on Treeview node click

Posted By: Aamrapali Tamgadge     Posted Date: May 17, 2011    Points:5   Category :ASP.Net
Hi. Me having one treeview and it has its subnode when i click on each of the node it should check the login session that it is login or not if it is already login den dont show the message otherwise show the popup msg like happens in bellow link

http://placement.freshersworld.com/www/sample-papers/placement-preparation.php?parentID=3&parentName=General%20Placement%20Preparation&subDirId=6&subDirName=Courses&subCatID=12&subcatName=Quantitative

Responses
Author: Mahesh             
Posted Date: May 17, 2011     Points: 20   

hi,
pls follow the link below,

http://www.daniweb.com/web-development/aspnet/threads/178014

hope this helps...

Thanks
Mahesh

Author: Aamrapali Tamgadge             
Posted Date: May 18, 2011     Points: 20   

Hi Mahesh Sir but me having all the nodes are static not any of data come from database so how can i check it. and display the msg

Software Programmer At OTIS ISRC
Author: Mahesh             
Posted Date: May 18, 2011     Points: 20   

hi,
check the code below,

--------------html--------------
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="WebApplication1._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script language="javascript" type="text/javascript">
// Gets the value of the searchKey
// from the NodeData of a TreeNode.
//
function GetKeyValue( searchKey )
{
alert('GetKeyValue');
// Get a handle to the selected TreeNode.
var treenode = GetSelectedNode();

// Validate the node handle.
if ( null == treenode || undefined == treenode )
return null;

// Get the node's NodeData property's value.
var nodeDataAry = treenode.getAttribute( 'nodeData' );

if ( null == nodeDataAry || undefined == nodeDataAry )
return null;

nodeDataAry = nodeDataAry.split( ';' );

if ( null == nodeDataAry || undefined == nodeDataAry ||
0 >= nodeDataAry.length )
return null;

var count = 0;
var returnValue = null;

while ( count < nodeDataAry.length )
{
var workingItem = nodeDataAry[ count ];

if ( 0 >= workingItem.length )
{
count++;
continue;
}

// Split the string into its key value pairs.
var kv = workingItem.split( '=' );

if ( 1 >= kv.length )
{
count++;
continue;
}

var key = kv[ 0 ];
var kValue = kv[ 1 ];

if ( key != searchKey )
{
count++;
continue;
}

returnValue = kValue;
break;
}

return returnValue;
}


// Gets a handle to the TreeView.
//
function GetTreeHandle()
{
alert('GetTreeHandle');
var tree;
var treeName = 'tvControl';

// Get a handle to the TreeView.
tree = document.getElementById( treeName );

if ( null == tree || undefined == tree )
return null;

return tree;
}

// Gets a handle to the TreeView's selected node.
//
function GetSelectedNode()
{
alert('GetSelectedNode');
var tree = GetTreeHandle();
var treeNode;

if ( null == tree || undefined == tree )
return null;

treeNode = tree.getTreeNode( tree.selectedNodeIndex );

if ( null == treeNode || undefined == treeNode )
return null;

return treeNode;
}

// Simply changes the information
// in the display text boxes to
// demonstrate how to obtain meta-data
// from the selected node's
// NodeData property on the client.
//
function ChangeText( eventName )
{
alert('ChangeText');
var treeNode = GetSelectedNode();

if ( null == treeNode || undefined == treeNode )
{
return;
}

var nodeData =
treeNode.getAttribute( 'nodeData' ).split( ';' );

var id = GetKeyValue( 'SomeId' );
var name = GetKeyValue( 'Name' );

document.getElementById( 'txtEvent' ).value =
eventName;
document.getElementById( 'txtId' ).value = id;
document.getElementById( 'txtName' ).value = name;
}

// Intercepts the double-click event on the client.
//
function TVDoubleClick()
{
alert('TVDoubleClick');
ChangeText( 'dblclick' );
}

// Intercepts the index changed event on the client.
//
function TVIndexChanged()
{
alert('TVIndexChanged');
ChangeText( 'node changed' );
}

</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TreeView ID="TreeView1" runat="server" Width="195px">

</asp:TreeView>
</div>
</form>
</body>
</html>
------------------------------

---------------vb code-------------
Partial Public Class _Default
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
TreeView1.Nodes.Clear()
' Create the root tree node.
Dim root As New TreeNode()
root.Text = "Root Parent Node"
root.Text = "SomeId=1000;Name=Mike Elliott"

' Create a child node.
Dim tn As New TreeNode()
tn.Text = "Child 1 of Root Parent"
tn.Text = "SomeId=1001;Name=Play For Sport, Inc."

' Add the child to the root node.
root.ChildNodes.Add(tn)

' Create another child node.
tn = New TreeNode()
tn.Text = "Child 2 or Root Parent"
tn.Text = "SomeId=1002;Name=Chip Oxendine"

' Create a grandchild node and add it to its parent.
Dim cn As New TreeNode()
cn.Text = "Grandchild of Root Parent"
cn.Text = "SomeId=1003;Name=Mike Elliott"
tn.ChildNodes.Add(cn)

' Add the child to the root node.
root.ChildNodes.Add(tn)
root.Expanded = True

' Add all the nodes to the tree view.
Me.TreeView1.Nodes.Add(root)

Me.OverRideServerEvents()

End Sub

Private Sub OverRideServerEvents()
' Create and wire up the javascript event handlers.
'
Dim clickHandler As String = "TVIndexChanged();"
Me.TreeView1.Attributes.Add("onselectedindexchange", clickHandler)

'clickHandler = "TVNodeExpand();"
'Me.TreeView1.Attributes.Add("onexpand", clickHandler)

'clickHandler = "TVNodeCollapse();"
'Me.TreeView1.Attributes.Add("oncollapse", clickHandler)

clickHandler = "TVDoubleClick();"
Me.TreeView1.Attributes.Add("onclick", clickHandler)

'clickHandler = "TVRightClick();"
'Me.TreeView1.Attributes.Add("oncontextmenu", clickHandler)
End Sub

End Class


hope this helps.....

Thanks
Mahesh




Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend