Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 1st, 2003, 10:42 AM
Authorized User
 
Join Date: Aug 2003
Location: , , United Kingdom.
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help! Treeview Error

Hi

I have used the Treeview active x object in vb many times and decided that I was going to use in an asp app showing the department hierarchy. However, despite following Microsoft's example I can't get it to work!
It returns the data and builds up the response.write correctly, however instead of building the tree, it writes the code into the browser window ie
TreeView1.Nodes.Add(,,'_-1','AWOL')TreeView1.Nodes.Add(-1, tvwChild, _0,AWOL System)TreeView1.Nodes.Add(0, tvwChild, _24,A)TreeView1.Nodes.Add(24, tvwChild, _23,B)TreeView1.Nodes.Add(24, tvwChild, _38,C)TreeView1.Nodes.Add(38, tvwChild, _33,D)TreeView1.Nodes.Add(38, tvwChild, _39,E)

Can anyone help or suggest another way of doing this?

Cheers
Lbob

My ASP code is as follows


<html>
<body>
<% BuildTree()%>

<OBJECT classid="clsid:C74190B6-8589-11D1-B16A-00C0F0283628" id=TreeView1 style="HEIGHT: 700px; LEFT: 0px; TOP: 0px; WIDTH: 325px">
<PARAM NAME="_ExtentX" VALUE="8599">
<PARAM NAME="_ExtentY" VALUE="18521">
<PARAM NAME="_Version" VALUE="393217">
<PARAM NAME="HideSelection" VALUE="0">
<PARAM NAME="Indentation" VALUE="741">
<PARAM NAME="LabelEdit" VALUE="1">
<PARAM NAME="LineStyle" VALUE="0">
<PARAM NAME="PathSeparator" VALUE="\">
<PARAM NAME="Sorted" VALUE="1">
<PARAM NAME="Style" VALUE="6">
<PARAM NAME="Checkboxes" VALUE="0">
<PARAM NAME="FullRowSelect" VALUE="0">
<PARAM NAME="HotTracking" VALUE="0">
<PARAM NAME="Scroll" VALUE="1">
<PARAM NAME="SingleSel" VALUE="0">
<PARAM NAME="ImageList" VALUE="">
<PARAM NAME="BorderStyle" VALUE="0">
<PARAM NAME="Appearance" VALUE="0">
<PARAM NAME="MousePointer" VALUE="0">
<PARAM NAME="Enabled" VALUE="1">
<PARAM NAME="OLEDragMode" VALUE="0">
<PARAM NAME="OLEDropMode" VALUE="0"></OBJECT>
</body>
</html>
<%
Sub BuildTree()

Dim nde

ssql = "select min(user_id) as min_user from users"

Set cnn = Server.CreateObject("Adodb.connection")
cnn.open "DSN=AWOL_Test", "sa"

Set rcst = Server.CreateObject("adodb.recordset")
Set rcst = cnn.execute(sSQL)

Response.Write "TreeView1.Nodes.Add(,,'_-1','AWOL')"
nde = "_-1"

users nde

rcst.Close
Set rcst = Nothing
cnn.close
set cnn = nothing

End Sub

Sub users(user_node)

user_id = right(user_node,len(user_node) -1)

ssql = "select user_id, first_name, last_name from users where manager_id =" & user_id

Set cnn = Server.CreateObject("Adodb.connection")
cnn.open "DSN=AWOL_Test", "sa"
Set rs = Server.CreateObject("adodb.recordset")
Set rs = cnn.execute(sSQL)

Do While Not rs.EOF

strSQL = "select count(manager_id) as count_manager from users where manager_id = " & rs("user_id")

Set rst = Server.CreateObject("adodb.recordset")
Set rst = cnn.execute(strSQL)

Dim nod
Response.Write "TreeView1.Nodes.Add(" & user_id & ", tvwChild, _" & rs("user_id") & "," & rs("first_name") & " " & rs("last_name") & ")"
If rst("count_manager") > 0 Then
users "_" & rs("user_id")
End If
rst.Close
Set rst = Nothing
rs.MoveNext
Loop
rs.Close
Set rs = Nothing

cnn.Close
set cnn = nothing

End Sub

%>:(

 
Old September 1st, 2003, 02:00 PM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

I don't know much about the Tree control, but it looks like you're trying to write (client-side??) VB Script for it, right?

In that case, you'll have to enclose the BuildTree function inside script tags:

<script language="vbscript">
    <% BuildTree %>
</script>

Does that help??

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old September 2nd, 2003, 03:31 AM
Authorized User
 
Join Date: Aug 2003
Location: , , United Kingdom.
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The thing is, it runs fine, its just that it displays the nodes as code, rather than enters them in the tree

 
Old September 2nd, 2003, 03:46 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Yes, because you have lines like this:
Response.Write "TreeView1.Nodes.Add(" & user_id & ", tvwChild, _" & rs("user_id") & "," & rs("first_name") & " " & rs("last_name") & ")"

so it just writes that out to the client. If you expect the client to run that code then you must do as Imar said, and write out a complete client-side script triggered by the onload event, then the treeview will be initialised and ready to act on the code you've generated.

hth
Phil
 
Old September 2nd, 2003, 05:08 AM
Authorized User
 
Join Date: Aug 2003
Location: , , United Kingdom.
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

ok thanks for that.
I tried what Imar said and I get an invalid character error!
lbob

 
Old September 2nd, 2003, 05:35 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Can you post the outcome of the Response statements??

Also, you need to call BuildTree after you have defined your <object> tag. The script generated by BuildTree will start to execute as soon as the page loads, but the <object> hasn't been generated yet at that time.

Alternatively (and preferably), do what Phil said and have BuildTree write out a function instead of directly executable code, and then call that function from the onload event of your page. This way, you can be sure that the tree view control has been initialized.

If this doesn't help, please be more specific about the error. Does the browser say that, or the ASP engine?


Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old September 2nd, 2003, 06:39 AM
Authorized User
 
Join Date: Aug 2003
Location: , , United Kingdom.
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

OK

Here's what I see if I do View Source. I also get an Invalid Character error on line 28 which is the response statement. Any ideas as I'm really stuck
Thanks
Lbob

<html>
<body>

<OBJECT classid="clsid:C74190B6-8589-11D1-B16A-00C0F0283628" id=TreeView1 style="HEIGHT: 700px; LEFT: 0px; TOP: 0px; WIDTH: 325px">
    <PARAM NAME="_ExtentX" VALUE="8599">
    <PARAM NAME="_ExtentY" VALUE="18521">
    <PARAM NAME="_Version" VALUE="393217">
    <PARAM NAME="HideSelection" VALUE="0">
    <PARAM NAME="Indentation" VALUE="741">
    <PARAM NAME="LabelEdit" VALUE="1">
    <PARAM NAME="LineStyle" VALUE="0">
    <PARAM NAME="PathSeparator" VALUE="\">
    <PARAM NAME="Sorted" VALUE="1">
    <PARAM NAME="Style" VALUE="6">
    <PARAM NAME="Checkboxes" VALUE="0">
    <PARAM NAME="FullRowSelect" VALUE="0">
    <PARAM NAME="HotTracking" VALUE="0">
    <PARAM NAME="Scroll" VALUE="1">
    <PARAM NAME="SingleSel" VALUE="0">
    <PARAM NAME="ImageList" VALUE="">
    <PARAM NAME="BorderStyle" VALUE="0">
    <PARAM NAME="Appearance" VALUE="0">
    <PARAM NAME="MousePointer" VALUE="0">
    <PARAM NAME="Enabled" VALUE="1">
    <PARAM NAME="OLEDragMode" VALUE="0">
    <PARAM NAME="OLEDropMode" VALUE="0"></OBJECT>
<script language="vbscript">
TreeView1.Nodes.Add(,,_0,AWOL)TreeView1.No des.Add(0, tvwChild, _24,Edg)TreeView1.Nodes.Add(24, tvwChild, _23,Mel)TreeView1.Nodes.Add(24, tvwChild, _38,Jer)TreeView1.Nodes.Add(38, tvwChild, _33,Vic)TreeView1.Nodes.Add(38, tvwChild, _39,Deb)TreeView1.Nodes.Add(39, tvwChild, _297,Dil)TreeView1.Nodes.Add(39, tvwChild, _300,Nig)TreeView1.Nodes.Add(39, tvwChild, _318,Ste)TreeView1.Nodes.Add(39, tvwChild, _303,Sun)TreeView1.Nodes.Add(39, tvwChild, _311,Lin)TreeView1.Nodes.Add(39, tvwChild, _312,Jai)TreeView1.Nodes.Add(39, tvwChild, _315,Bha)TreeView1.Nodes.Add(38, tvwChild, _290,Car)TreeView1.Nodes.Add(290, tvwChild, _291,Des)TreeView1.Nodes.Add(290, tvwChild, _292,Sim)TreeView1.Nodes.Add(290, tvwChild, _298,Sar)TreeView1.Nodes.Add(290, tvwChild, _301,Alu)TreeView1.Nodes.Add(290, tvwChild, _305,Ste)TreeView1.Nodes.Add(290, tvwChild, _306,Dav)TreeView1.Nodes.Add(290, tvwChild, _307,Pim)TreeView1.Nodes.Add(290, tvwChild, _308,Jos)TreeView1.Nodes.Add(290, tvwChild, _309,Law)TreeView1.Nodes.Add(290, tvwChild, _310,Rac)TreeView1.Nodes.Add(290, tvwChild, _313,Jas)TreeView1.Nodes.Add(290, tvwChild, _314,Gar)TreeView1.Nodes.Add(290, tvwChild, _316,Mic)TreeView1.Nodes.Add(24, tvwChild, _10,Mik)TreeView1.Nodes.Add(10, tvwChild, _13,Kar)TreeView1.Nodes.Add(10, tvwChild, _9,Cra)TreeView1.Nodes.Add(9, tvwChild, _1,And)TreeView1.Nodes.Add(1, tvwChild, _2,Lyn)TreeView1.Nodes.Add(1, tvwChild, _4,Ste)TreeView1.Nodes.Add(1, tvwChild, _3,Pet)TreeView1.Nodes.Add(9, tvwChild, _5,Sha)TreeView1.Nodes.Add(5, tvwChild, _199,San)TreeView1.Nodes.Add(5, tvwChild, _7,Ala)TreeView1.Nodes.Add(5, tvwChild, _196,Che)TreeView1.Nodes.Add(5, tvwChild, _197,Aru)TreeView1.Nodes.Add(5, tvwChild, _198,Pri)TreeView1.Nodes.Add(5, tvwChild, _6,Tra)TreeView1.Nodes.Add(5, tvwChild, _8,Dav)TreeView1.Nodes.Add(9, tvwChild, _177,Cha)TreeView1.Nodes.Add(177, tvwChild, _180,Gar)TreeView1.Nodes.Add(177, tvwChild, _179,And)TreeView1.Nodes.Add(177, tvwChild, _182,Nea)TreeView1.Nodes.Add(177, tvwChild, _178,Akb)TreeView1.Nodes.Add(177, tvwChild, _181,Nat)TreeView1.Nodes.Add(177, tvwChild, _183,Sha)TreeView1.Nodes.Add(9, tvwChild, _263,Pri)TreeView1.Nodes.Add(263, tvwChild, _264,Jul)TreeView1.Nodes.Add(263, tvwChild, _265,Gar)TreeView1.Nodes.Add(263, tvwChild, _266,Mat)TreeView1.Nodes.Add(263, tvwChild, _267,Jus)TreeView1.Nodes.Add(9, tvwChild, _270,Jon)TreeView1.Nodes.Add(270, tvwChild, _269,Nig)TreeView1.Nodes.Add(270, tvwChild, _271,Rod)TreeView1.Nodes.Add(271, tvwChild, _277,Col)TreeView1.Nodes.Add(270, tvwChild, _272,And)TreeView1.Nodes.Add(272, tvwChild, _278,Sin)TreeView1.Nodes.Add(270, tvwChild, _274,Kar)TreeView1.Nodes.Add(274, tvwChild, _279,Tim)TreeView1.Nodes.Add(270, tvwChild, _275,Pie)TreeView1.Nodes.Add(270, tvwChild, _276,Ste)TreeView1.Nodes.Add(9, tvwChild, _282,Chr)TreeView1.Nodes.Add(10, tvwChild, _31,Nic)TreeView1.Nodes.Add(10, tvwChild, _25,Col)TreeView1.Nodes.Add(25, tvwChild, _29,Pau)TreeView1.Nodes.Add(25, tvwChild, _164,Ros)TreeView1.Nodes.Add(25, tvwChild, _28,Sim)TreeView1.Nodes.Add(10, tvwChild, _43,Ant)TreeView1.Nodes.Add(43, tvwChild, _62,Dam)TreeView1.Nodes.Add(62, tvwChild, _66,Nei)TreeView1.Nodes.Add(66, tvwChild, _48,Hol)TreeView1.Nodes.Add(66, tvwChild, _53,Ste)TreeView1.Nodes.Add(66, tvwChild, _55,Joh)TreeView1.Nodes.Add(66, tvwChild, _47,Dar)TreeView1.Nodes.Add(66, tvwChild, _49,Col)TreeView1.Nodes.Add(66, tvwChild, _51,Pau)TreeView1.Nodes.Add(66, tvwChild, _52,Pau)TreeView1.Nodes.Add(66, tvwChild, _54,Vid)TreeView1.Nodes.Add(66, tvwChild, _122,Bam)TreeView1.Nodes.Add(62, tvwChild, _64,Mik)TreeView1.Nodes.Add(64, tvwChild, _83,Dav)TreeView1.Nodes.Add(64, tvwChild, _96,And)TreeView1.Nodes.Add(64, tvwChild, _98,Nig)TreeView1.Nodes.Add(64, tvwChild, _102,Sim)TreeView1.Nodes.Add(64, tvwChild, _166,Phi)TreeView1.Nodes.Add(64, tvwChild, _79,Hel)TreeView1.Nodes.Add(64, tvwChild, _105,Tim)TreeView1.Nodes.Add(64, tvwChild, _106,Pat)TreeView1.Nodes.Add(64, tvwChild, _129,Rha)TreeView1.Nodes.Add(64, tvwChild, _135,Yog)TreeView1.Nodes.Add(64, tvwChild, _84,Fre)TreeView1.Nodes.Add(64, tvwChild, _134,Ton)TreeView1.Nodes.Add(62, tvwChild, _65,Bry)TreeView1.Nodes.Add(65, tvwChild, _78,Pau)TreeView1.Nodes.Add(65, tvwChild, _94,Tim)TreeView1.Nodes.Add(65, tvwChild, _130,Hit)TreeView1.Nodes.Add(62, tvwChild, _68,Pau)TreeView1.Nodes.Add(68, tvwChild, _104,Tom)TreeView1.Nodes.Add(104, tvwChild, _73,Ger)TreeView1.Nodes.Add(68, tvwChild, _320,Ton)TreeView1.Nodes.Add(68, tvwChild, _97,Jer)TreeView1.Nodes.Add(68, tvwChild, _75,Pet)TreeView1.Nodes.Add(68, tvwChild, _81,Pol)TreeView1.Nodes.Add(81, tvwChild, _107,Dip)TreeView1.Nodes.Add(81, tvwChild, _176,Geo)TreeView1.Nodes.Add(81, tvwChild, _128,Aja)TreeView1.Nodes.Add(68, tvwChild, _123,Far)TreeView1.Nodes.Add(68, tvwChild, _171,Ste)TreeView1.Nodes.Add(68, tvwChild, _175,San)TreeView1.Nodes.Add(62, tvwChild, _67,Ste)TreeView1.Nodes.Add(67, tvwChild, _101,Dal)TreeView1.Nodes.Add(67, tvwChild, _77,And)TreeView1.Nodes.Add(67, tvwChild, _82,Dar)TreeView1.Nodes.Add(67, tvwChild, _167,Dav)TreeView1.Nodes.Add(67, tvwChild, _168,Cha)TreeView1.Nodes.Add(67, tvwChild, _169,Noe)TreeView1.Nodes.Add(67, tvwChild, _170,Hel)TreeView1.Nodes.Add(43, tvwChild, _60,And)TreeView1.Nodes.Add(60, tvwChild, _72,Hin)TreeView1.Nodes.Add(43, tvwChild, _59,Din)TreeView1.Nodes.Add(59, tvwChild, _71,Asi)TreeView1.Nodes.Add(59, tvwChild, _58,Kar)TreeView1.Nodes.Add(59, tvwChild, _69,Bru)TreeView1.Nodes.Add(69, tvwChild, _76,Sim)TreeView1.Nodes.Add(69, tvwChild, _108,Mar)TreeView1.Nodes.Add(59, tvwChild, _70,Ray)TreeView1.Nodes.Add(70, tvwChild, _109,Son)TreeView1.Nodes.Add(59, tvwChild, _95,Dom)TreeView1.Nodes.Add(59, tvwChild, _131,Joh)TreeView1.Nodes.Add(59, tvwChild, _165,Man)TreeView1.Nodes.Add(59, tvwChild, _80,Rob)TreeView1.Nodes.Add(24, tvwChild, _268,Jac)TreeView1.Nodes.Add(0, tvwChild, _61,Mik)TreeView1.Nodes.Add(61, tvwChild, _15,Ste)TreeView1.Nodes.Add(15, tvwChild, _19,Mar)TreeView1.Nodes.Add(19, tvwChild, _20,Ste)TreeView1.Nodes.Add(20, tvwChild, _118,Jim)TreeView1.Nodes.Add(20, tvwChild, _119,Dan)TreeView1.Nodes.Add(20, tvwChild, _117,Pau)TreeView1.Nodes.Add(20, tvwChild, _121,Mic)TreeView1.Nodes.Add(19, tvwChild, _21,Chr)TreeView1.Nodes.Add(19, tvwChild, _22,Nic)TreeView1.Nodes.Add(22, tvwChild, _88,Vas)TreeView1.Nodes.Add(22, tvwChild, _93,Rac)TreeView1.Nodes.Add(22, tvwChild, _112,Aur)TreeView1.Nodes.Add(22, tvwChild, _89,Ang)TreeView1.Nodes.Add(22, tvwChild, _113,Guy)TreeView1.Nodes.Add(22, tvwChild, _114,Kar)TreeView1.Nodes.Add(22, tvwChild, _115,Ter)TreeView1.Nodes.Add(22, tvwChild, _85,Mag)TreeView1.Nodes.Add(22, tvwChild, _86,Rat)TreeView1.Nodes.Add(22, tvwChild, _87,Ito)TreeView1.Nodes.Add(22, tvwChild, _90,Ste)TreeView1.Nodes.Add(22, tvwChild, _91,Gar)TreeView1.Nodes.Add(22, tvwChild, _319,Dar)TreeView1.Nodes.Add(19, tvwChild, _281,Var)TreeView1.Nodes.Add(19, tvwChild, _283,And)TreeView1.Nodes.Add(283, tvwChild, _284,Stu)TreeView1.Nodes.Add(283, tvwChild, _285,Hem)TreeView1.Nodes.Add(283, tvwChild, _286,Stu)TreeView1.Nodes.Add(283, tvwChild, _287,Int)TreeView1.Nodes.Add(283, tvwChild, _288,Ray)TreeView1.Nodes.Add(283, tvwChild, _289,Dar)TreeView1.Nodes.Add(15, tvwChild, _37,Sim)TreeView1.Nodes.Add(37, tvwChild, _92,Ann)TreeView1.Nodes.Add(37, tvwChild, _137,Tar)TreeView1.Nodes.Add(37, tvwChild, _280,Dav)TreeView1.Nodes.Add(37, tvwChild, _295,Mim)TreeView1.Nodes.Add(15, tvwChild, _17,Avt)TreeView1.Nodes.Add(17, tvwChild, _124,She)TreeView1.Nodes.Add(17, tvwChild, _125,Daw)TreeView1.Nodes.Add(17, tvwChild, _126,Ama)TreeView1.Nodes.Add(17, tvwChild, _127,Kar)TreeView1.Nodes.Add(15, tvwChild, _18,Joh)TreeView1.Nodes.Add(18, tvwChild, _138,Gur)TreeView1.Nodes.Add(18, tvwChild, _242,Lis)TreeView1.Nodes.Add(18, tvwChild, _243,Don)TreeView1.Nodes.Add(18, tvwChild, _244,Kir)TreeView1.Nodes.Add(18, tvwChild, _245,Bro)TreeView1.Nodes.Add(18, tvwChild, _246,Jus)TreeView1.Nodes.Add(18, tvwChild, _247,Pet)TreeView1.Nodes.Add(18, tvwChild, _136,Mar)TreeView1.Nodes.Add(15, tvwChild, _14,Mar)TreeView1.Nodes.Add(15, tvwChild, _16,Daf)TreeView1.Nodes.Add(16, tvwChild, _140,Pet)TreeView1.Nodes.Add(140, tvwChild, _206,Dav)TreeView1.Nodes.Add(206, tvwChild, _229,Stu)TreeView1.Nodes.Add(206, tvwChild, _230,Nea)TreeView1.Nodes.Add(206, tvwChild, _231,Adr)TreeView1.Nodes.Add(206, tvwChild, _232,Dav)TreeView1.Nodes.Add(206, tvwChild, _233,Sue)TreeView1.Nodes.Add(206, tvwChild, _234,Hea)TreeView1.Nodes.Add(206, tvwChild, _235,Nik)TreeView1.Nodes.Add(206, tvwChild, _236,Rob)TreeView1.Nodes.Add(206, tvwChild, _237,Stu)TreeView1.Nodes.Add(206, tvwChild, _238,Tim)TreeView1.Nodes.Add(206, tvwChild, _239,Mic)TreeView1.Nodes.Add(206, tvwChild, _240,Rus)TreeView1.Nodes.Add(206, tvwChild, _241,Sue)TreeView1.Nodes.Add(140, tvwChild, _207,Jim)TreeView1.Nodes.Add(207, tvwChild, _220,Sea)TreeView1.Nodes.Add(207, tvwChild, _221,Tim)TreeView1.Nodes.Add(207, tvwChild, _222,Waq)TreeView1.Nodes.Add(207, tvwChild, _223,Joh)TreeView1.Nodes.Add(207, tvwChild, _224,Fit)TreeView1.Nodes.Add(207, tvwChild, _225,Joh)TreeView1.Nodes.Add(207, tvwChild, _226,And)TreeView1.Nodes.Add(207, tvwChild, _227,Rob)TreeView1.Nodes.Add(207, tvwChild, _228,Nic)TreeView1.Nodes.Add(140, tvwChild, _208,Chi)TreeView1.Nodes.Add(208, tvwChild, _215,Mar)TreeView1.Nodes.Add(208, tvwChild, _216,Nam)TreeView1.Nodes.Add(208, tvwChild, _217,Qui)TreeView1.Nodes.Add(208, tvwChild, _218,Sat)TreeView1.Nodes.Add(208, tvwChild, _219,Tre)TreeView1.Nodes.Add(140, tvwChild, _209,Aru)TreeView1.Nodes.Add(209, tvwChild, _213,Dom)TreeView1.Nodes.Add(209, tvwChild, _214,Way)TreeView1.Nodes.Add(140, tvwChild, _210,Mar)TreeView1.Nodes.Add(210, tvwChild, _211,Pip)TreeView1.Nodes.Add(210, tvwChild, _212,Dan)TreeView1.Nodes.Add(140, tvwChild, _256,Ste)TreeView1.Nodes.Add(140, tvwChild, _257,Eil)TreeView1.Nodes.Add(140, tvwChild, _258,Jul)TreeView1.Nodes.Add(140, tvwChild, _259,Edd)TreeView1.Nodes.Add(140, tvwChild, _260,Jim)TreeView1.Nodes.Add(140, tvwChild, _261,How)TreeView1.Nodes.Add(140, tvwChild, _262,Ver)TreeView1.Nodes.Add(140, tvwChild, _294,Gre)TreeView1.Nodes.Add(16, tvwChild, _139,Cli)TreeView1.Nodes.Add(139, tvwChild, _248,Ron)TreeView1.Nodes.Add(139, tvwChild, _249,Hel)TreeView1.Nodes.Add(139, tvwChild, _250,Sim)TreeView1.Nodes.Add(139, tvwChild, _251,And)TreeView1.Nodes.Add(139, tvwChild, _184,Lyn)TreeView1.Nodes.Add(184, tvwChild, _185,Jac)TreeView1.Nodes.Add(184, tvwChild, _186,Lis)TreeView1.Nodes.Add(184, tvwChild, _187,Ame)TreeView1.Nodes.Add(139, tvwChild, _141,Rup)TreeView1.Nodes.Add(141, tvwChild, _158,Sco)TreeView1.Nodes.Add(141, tvwChild, _159,Gul)TreeView1.Nodes.Add(141, tvwChild, _160,Phi)TreeView1.Nodes.Add(141, tvwChild, _163,Ste)TreeView1.Nodes.Add(141, tvwChild, _154,Mar)TreeView1.Nodes.Add(141, tvwChild, _161,The)TreeView1.Nodes.Add(141, tvwChild, _155,Jas)TreeView1.Nodes.Add(141, tvwChild, _156,Geo)TreeView1.Nodes.Add(141, tvwChild, _157,Man)TreeView1.Nodes.Add(141, tvwChild, _162,Sha)TreeView1.Nodes.Add(141, tvwChild, _317,Mar)TreeView1.Nodes.Add(139, tvwChild, _153,Bob)TreeView1.Nodes.Add(153, tvwChild, _201,Dou)TreeView1.Nodes.Add(153, tvwChild, _202,Gar)TreeView1.Nodes.Add(153, tvwChild, _203,Jus)TreeView1.Nodes.Add(153, tvwChild, _204,Mar)TreeView1.Nodes.Add(153, tvwChild, _205,Pet)TreeView1.Nodes.Add(153, tvwChild, _188,Pau)TreeView1.Nodes.Add(153, tvwChild, _189,Mau)TreeView1.Nodes.Add(153, tvwChild, _191,Mar)TreeView1.Nodes.Add(153, tvwChild, _192,Ter)TreeView1.Nodes.Add(153, tvwChild, _193,Chi)TreeView1.Nodes.Add(153, tvwChild, _194,Pet)TreeView1.Nodes.Add(153, tvwChild, _190,Rog)TreeView1.Nodes.Add(153, tvwChild, _195,Iva)TreeView1.Nodes.Add(153, tvwChild, _293,Dav)TreeView1.Nodes.Add(139, tvwChild, _252,Nic)TreeView1.Nodes.Add(139, tvwChild, _253,And)TreeView1.Nodes.Add(139, tvwChild, _254,And)TreeView1.Nodes.Add(139, tvwChild, _255,Jo)TreeView1.Nodes.Add(16, tvwChild, _296,Stu)
</script>
</body>
</html>


 
Old September 2nd, 2003, 07:42 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

OK lbob I can see you're having a bit of trouble, so lets go back to basics.

You're trying to use asp to generate vbscript which will be run on the client. In complicated situations like this I find it v helpful to step back from asp and consider what you would need to put in a plain HTML page to make it display the tree you want. Only when this is sorted should you turn to asp and attempt to generate that html/script.

For example, an HTML page such as this will generate a tree with 2 nodes, where the 2nd is a child of the 1st:
Code:
<html>
</head>
<script language="vbscript">
Sub InitTree()
    Call TreeView1.Nodes.Add(,,"_0","AWOL")
    Call TreeView1.Nodes.Add("_0", 4, "_24","Edg")
End Sub
</script>
</head>
<body onload="InitTree">
<OBJECT classid="clsid:C74190B6-8589-11D1-B16A-00C0F0283628" id=TreeView1 style="HEIGHT: 700px; LEFT: 0px; TOP: 0px; WIDTH: 325px" VIEWASTEXT>
    <PARAM NAME="_ExtentX" VALUE="8599">
    <PARAM NAME="_ExtentY" VALUE="18521">
    <PARAM NAME="_Version" VALUE="393217">
    <PARAM NAME="HideSelection" VALUE="0">
    <PARAM NAME="Indentation" VALUE="741">
    <PARAM NAME="LabelEdit" VALUE="1">
    <PARAM NAME="LineStyle" VALUE="0">
    <PARAM NAME="PathSeparator" VALUE="\">
    <PARAM NAME="Sorted" VALUE="1">
    <PARAM NAME="Style" VALUE="6">
    <PARAM NAME="Checkboxes" VALUE="0">
    <PARAM NAME="FullRowSelect" VALUE="0">
    <PARAM NAME="HotTracking" VALUE="0">
    <PARAM NAME="Scroll" VALUE="1">
    <PARAM NAME="SingleSel" VALUE="0">
    <PARAM NAME="ImageList" VALUE="">
    <PARAM NAME="BorderStyle" VALUE="0">
    <PARAM NAME="Appearance" VALUE="0">
    <PARAM NAME="MousePointer" VALUE="0">
    <PARAM NAME="Enabled" VALUE="1">
    <PARAM NAME="OLEDragMode" VALUE="0">
    <PARAM NAME="OLEDropMode" VALUE="0"></OBJECT>
</body>
</html>
now look at the difference between that and the html which your asp page has generated
Code:
<html>
<body>

<OBJECT classid="clsid:C74190B6-8589-11D1-B16A-00C0F0283628" id=TreeView1 style="HEIGHT: 700px; LEFT: 0px; TOP: 0px; WIDTH: 325px">
    <PARAM NAME="_ExtentX" VALUE="8599">
    <PARAM NAME="_ExtentY" VALUE="18521">
    <PARAM NAME="_Version" VALUE="393217">
    <PARAM NAME="HideSelection" VALUE="0">
    <PARAM NAME="Indentation" VALUE="741">
    <PARAM NAME="LabelEdit" VALUE="1">
    <PARAM NAME="LineStyle" VALUE="0">
    <PARAM NAME="PathSeparator" VALUE="\">
    <PARAM NAME="Sorted" VALUE="1">
    <PARAM NAME="Style" VALUE="6">
    <PARAM NAME="Checkboxes" VALUE="0">
    <PARAM NAME="FullRowSelect" VALUE="0">
    <PARAM NAME="HotTracking" VALUE="0">
    <PARAM NAME="Scroll" VALUE="1">
    <PARAM NAME="SingleSel" VALUE="0">
    <PARAM NAME="ImageList" VALUE="">
    <PARAM NAME="BorderStyle" VALUE="0">
    <PARAM NAME="Appearance" VALUE="0">
    <PARAM NAME="MousePointer" VALUE="0">
    <PARAM NAME="Enabled" VALUE="1">
    <PARAM NAME="OLEDragMode" VALUE="0">
    <PARAM NAME="OLEDropMode" VALUE="0"></OBJECT>
<script language="vbscript">
    TreeView1.Nodes.Add(,,_0,AWOL)TreeView1.Nodes.Add(0, tvwChild, _24,Edg)TreeView1.Nodes.Add(24, tvwChild, _23,Mel)...clipped
</script>
</body>
</html>
there are a few noticeable differences:
1. your code is not wrapped in a Sub which is called from the onload event. This means that the browser will attempt to execute your code as soon as it reads it. This will fail unless the treeview control has been properly initialised at the time the code is run by the browser(hence why I moved the script into a Sub in the <head> section)
2. you need to get basic syntax sorted:
  2.1 each line of code must start on a new line, try adding vbCrLf after each line
  2.2 you're treating the Add as a Sub, so if you have parentheses you must use Call...
  2.3 the arguments to the Add must be of the correct data type, so you must put " around any strings (that accounts for your invalid character error)
3. you'll probably need to define the constant tvwChild (=4) in your client-side vbscript

hth
Phil
 
Old September 2nd, 2003, 09:14 AM
Authorized User
 
Join Date: Aug 2003
Location: , , United Kingdom.
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Cheers Phil

I've managed to get it all working now, my only gripe is that it is slow processing it. Any ideas how this can be rectified?

Thanks once again
Lbob





 
Old September 3rd, 2003, 02:36 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi lbob, glad its working now. When you say its slow, do you mean its slow to display the page in the first place, or its slow reacting to the treeview in the browser, or both?




Similar Threads
Thread Thread Starter Forum Replies Last Post
treeview SAIGORTI SQL Language 2 September 6th, 2005 07:31 PM
Treeview dkr72 VBScript 0 November 9th, 2004 12:07 PM
treeview suzila Javascript 1 December 3rd, 2003 07:07 AM
TreeView karpagameena C# 1 September 7th, 2003 04:38 AM
Treeview shiju ADO.NET 0 August 22nd, 2003 10:22 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.