473,748 Members | 9,416 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to use Javascript to add Treeview control

Hello,

We are inserting a side menu to our application using a class that is
writing HTML on all our pages. This is a part of the code as an
example:

writer.Write(" <table WIDTH=""100%"" BORDER=""0"" CELLSPACING=""0 ""
CELLPADDING=""0 "" ID=""Table1""> " & vbNewLine)
writer.Write(" <tr>" & vbNewLine)
writer.Write(" <td>" & vbNewLine)
writer.Write(" <table width=""100%"" border=""0""
cellspacing=""0 "" cellpadding=""0 ""> " & vbNewLine)
writer.Write(" <tr> " & vbNewLine)
writer.Write(" <td width=""124""
valign=""top"" bgcolor=""#f1f1 f1"" height=""100%"" ><img alt=""image""
src=""images/spacer.gif"" width=""1"" height=""10"">< br> " & vbNewLine)
writer.Write(" <table width=""124""
border=""0"" cellspacing=""0 "" cellpadding=""2 ""> " & vbNewLine)

We used to write a Javascript menu this way, and it worked just fine.
Now I'm trying to use a Treeview control instead of JS menu.

So I created a web control treeview.ascx and put a control there. It
works just fine if I use it usual way.

Now I'm trying to use it in our class that writes HTML. I thought that
all I need to do is to add these lines:

writer.Write(" <%@ Register TagPrefix=""uc1 "" TagName=""treev iew""
Src=""treeview. ascx"" %>")
writer.Write(" <%@ Register TagPrefix=""iew c""
Namespace=""Mic rosoft.Web.UI.W ebControls""
Assembly=""Micr osoft.Web.UI.We bControls"" %>")

............... ............... ......

writer.Write("
<uc1:treeview id=""Treeview2" " runat=""server" "></uc1:treeview>" &
vbNewLine)

It doesn't work, the treeview control is not visible. I've tried
different options, even to write the whole HTML of this control - no
luck.

What am I doing wrong? All this class does is writes HTML that
otherwise I put directly on the page where everything works great.

I would appreciate your advice.

Thank you,

Peter

Nov 19 '05 #1
3 2832
Hi Peter,

The Treeview is an ASP.NET server-side control--that is, there is a whole
lot of HTML generated by the server. That UserControl tag acts to specify
the properties the server uses to render the control, but that is not the
actual HTML of the control. So, you can't generate the ASP.NET Treeview
control client-side (i.e. via Javascript).

You can, however, look for other, Javascript-based Treeviews that render on
the client-side.

--

Joshua Mitts
jo****@msn.com

"Peter" <pv*@speakeasy. net> wrote in message
news:11******** **************@ g47g2000cwa.goo glegroups.com.. .
Hello,

We are inserting a side menu to our application using a class that is
writing HTML on all our pages. This is a part of the code as an
example:

writer.Write(" <table WIDTH=""100%"" BORDER=""0"" CELLSPACING=""0 ""
CELLPADDING=""0 "" ID=""Table1""> " & vbNewLine)
writer.Write(" <tr>" & vbNewLine)
writer.Write(" <td>" & vbNewLine)
writer.Write(" <table width=""100%"" border=""0""
cellspacing=""0 "" cellpadding=""0 ""> " & vbNewLine)
writer.Write(" <tr> " & vbNewLine)
writer.Write(" <td width=""124""
valign=""top"" bgcolor=""#f1f1 f1"" height=""100%"" ><img alt=""image""
src=""images/spacer.gif"" width=""1"" height=""10"">< br> " & vbNewLine)
writer.Write(" <table width=""124""
border=""0"" cellspacing=""0 "" cellpadding=""2 ""> " & vbNewLine)

We used to write a Javascript menu this way, and it worked just fine.
Now I'm trying to use a Treeview control instead of JS menu.

So I created a web control treeview.ascx and put a control there. It
works just fine if I use it usual way.

Now I'm trying to use it in our class that writes HTML. I thought that
all I need to do is to add these lines:

writer.Write(" <%@ Register TagPrefix=""uc1 "" TagName=""treev iew""
Src=""treeview. ascx"" %>")
writer.Write(" <%@ Register TagPrefix=""iew c""
Namespace=""Mic rosoft.Web.UI.W ebControls""
Assembly=""Micr osoft.Web.UI.We bControls"" %>")

............... ............... .....

writer.Write("
<uc1:treeview id=""Treeview2" " runat=""server" "></uc1:treeview>" &
vbNewLine)

It doesn't work, the treeview control is not visible. I've tried
different options, even to write the whole HTML of this control - no
luck.

What am I doing wrong? All this class does is writes HTML that
otherwise I put directly on the page where everything works great.

I would appreciate your advice.

Thank you,

Peter

Nov 19 '05 #2
Hi Joshua,

Thank you for your response.

But in this case I'm only inserting an ascx file, the control itself is in
treeview.ascx. Still won't work?

Thank you,

Peter

"Joshua Mitts" <jo****@msn.com > wrote in message
news:eR******** ********@TK2MSF TNGP15.phx.gbl. ..
Hi Peter,

The Treeview is an ASP.NET server-side control--that is, there is a whole
lot of HTML generated by the server. That UserControl tag acts to specify
the properties the server uses to render the control, but that is not the
actual HTML of the control. So, you can't generate the ASP.NET Treeview
control client-side (i.e. via Javascript).

You can, however, look for other, Javascript-based Treeviews that render on the client-side.

--

Joshua Mitts
jo****@msn.com

"Peter" <pv*@speakeasy. net> wrote in message
news:11******** **************@ g47g2000cwa.goo glegroups.com.. .
Hello,

We are inserting a side menu to our application using a class that is
writing HTML on all our pages. This is a part of the code as an
example:

writer.Write(" <table WIDTH=""100%"" BORDER=""0"" CELLSPACING=""0 ""
CELLPADDING=""0 "" ID=""Table1""> " & vbNewLine)
writer.Write(" <tr>" & vbNewLine)
writer.Write(" <td>" & vbNewLine)
writer.Write(" <table width=""100%"" border=""0""
cellspacing=""0 "" cellpadding=""0 ""> " & vbNewLine)
writer.Write(" <tr> " & vbNewLine)
writer.Write(" <td width=""124""
valign=""top"" bgcolor=""#f1f1 f1"" height=""100%"" ><img alt=""image""
src=""images/spacer.gif"" width=""1"" height=""10"">< br> " & vbNewLine)
writer.Write(" <table width=""124""
border=""0"" cellspacing=""0 "" cellpadding=""2 ""> " & vbNewLine)

We used to write a Javascript menu this way, and it worked just fine.
Now I'm trying to use a Treeview control instead of JS menu.

So I created a web control treeview.ascx and put a control there. It
works just fine if I use it usual way.

Now I'm trying to use it in our class that writes HTML. I thought that
all I need to do is to add these lines:

writer.Write(" <%@ Register TagPrefix=""uc1 "" TagName=""treev iew""
Src=""treeview. ascx"" %>")
writer.Write(" <%@ Register TagPrefix=""iew c""
Namespace=""Mic rosoft.Web.UI.W ebControls""
Assembly=""Micr osoft.Web.UI.We bControls"" %>")

............... ............... .....

writer.Write("
<uc1:treeview id=""Treeview2" " runat=""server" "></uc1:treeview>" &
vbNewLine)

It doesn't work, the treeview control is not visible. I've tried
different options, even to write the whole HTML of this control - no
luck.

What am I doing wrong? All this class does is writes HTML that
otherwise I put directly on the page where everything works great.

I would appreciate your advice.

Thank you,

Peter


Nov 19 '05 #3
Joshua hope you understood Joshua's adviced?
Hope you have gone through:- http://msdn.microsoft.com/workshop/
webcontrols/overview/treeview.asp
Patrick
"Peter Afonin" <pv*@speakeasy. net> wrote in message
news:us******** ******@TK2MSFTN GP09.phx.gbl...
Hi Joshua,

Thank you for your response.

But in this case I'm only inserting an ascx file, the control itself is in
treeview.ascx. Still won't work?

Thank you,

Peter

"Joshua Mitts" <jo****@msn.com > wrote in message
news:eR******** ********@TK2MSF TNGP15.phx.gbl. ..
Hi Peter,

The Treeview is an ASP.NET server-side control--that is, there is a whole lot of HTML generated by the server. That UserControl tag acts to specify the properties the server uses to render the control, but that is not the actual HTML of the control. So, you can't generate the ASP.NET Treeview
control client-side (i.e. via Javascript).

You can, however, look for other, Javascript-based Treeviews that render

on
the client-side.

--

Joshua Mitts
jo****@msn.com

"Peter" <pv*@speakeasy. net> wrote in message
news:11******** **************@ g47g2000cwa.goo glegroups.com.. .
Hello,

We are inserting a side menu to our application using a class that is
writing HTML on all our pages. This is a part of the code as an
example:

writer.Write(" <table WIDTH=""100%"" BORDER=""0"" CELLSPACING=""0 "" CELLPADDING=""0 "" ID=""Table1""> " & vbNewLine)
writer.Write(" <tr>" & vbNewLine)
writer.Write(" <td>" & vbNewLine)
writer.Write(" <table width=""100%"" border=""0""
cellspacing=""0 "" cellpadding=""0 ""> " & vbNewLine)
writer.Write(" <tr> " & vbNewLine)
writer.Write(" <td width=""124""
valign=""top"" bgcolor=""#f1f1 f1"" height=""100%"" ><img alt=""image""
src=""images/spacer.gif"" width=""1"" height=""10"">< br> " & vbNewLine) writer.Write(" <table width=""124""
border=""0"" cellspacing=""0 "" cellpadding=""2 ""> " & vbNewLine)

We used to write a Javascript menu this way, and it worked just fine.
Now I'm trying to use a Treeview control instead of JS menu.

So I created a web control treeview.ascx and put a control there. It
works just fine if I use it usual way.

Now I'm trying to use it in our class that writes HTML. I thought that
all I need to do is to add these lines:

writer.Write(" <%@ Register TagPrefix=""uc1 "" TagName=""treev iew""
Src=""treeview. ascx"" %>")
writer.Write(" <%@ Register TagPrefix=""iew c""
Namespace=""Mic rosoft.Web.UI.W ebControls""
Assembly=""Micr osoft.Web.UI.We bControls"" %>")

............... ............... .....

writer.Write("
<uc1:treeview id=""Treeview2" " runat=""server" "></uc1:treeview>" &
vbNewLine)

It doesn't work, the treeview control is not visible. I've tried
different options, even to write the whole HTML of this control - no
luck.

What am I doing wrong? All this class does is writes HTML that
otherwise I put directly on the page where everything works great.

I would appreciate your advice.

Thank you,

Peter



Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
19891
by: SoKool | last post by:
Can anyone point me to a site where I can get a free treeview control to use in ASP .NET or any tutorial that can help me build my own treeview control. I intend to use a treeview to generate a dynamic menu by collating data from a Sql Server Table. Many thanks.
8
4407
by: Hrvoje Voda | last post by:
What is wrong in this code? private void tree_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { if (e.KeyCode == Keys.Enter ) {
0
1169
by: Amir Ghezelbash | last post by:
Hello, I had a question, i am using TreeView provided with asp.net 2.0, greate control..but sadly it dosenot have drag and drop functionality..so i decided to add it my self ..i have worte the javascript that does draging and dropping, but I am having a problem adding this javascript to the treeview.. i think i somehow have to add the attribute to the treeview control in C# behind code before it renders it ...but dont know how to grab...
4
14180
by: Ben Coats | last post by:
Hey, I'm trying to find code for an Explorer-style Directory ComboBox. (You know, it display "Desktop", "My Computer", all drives, etc., but it has a treeview control inside the combobox so that you can navigate through the file system as well.) I've found some on the web, but all of them just have the drives and desktop directories and are static in that you cannot expand the directories. I normally build a treeview control to do it with,...
10
2364
by: p3t3r | last post by:
I have a treeview sourced from a SiteMap. I want to use 2 different CSS styles for the root level nodes. The topmost root node should not have a top border, all the other root nodes should have a top border. Is it possible to have more than 1 style at the same level (parent node) when using a SiteMap? I want it to appear something like this and I can only find a way to either have the border on all root nodes or none at all. In...
1
2563
by: musosdev | last post by:
Hi guys I was using the Microsoft.Web.UI.WebControls extra namespace in my application to provide me with a TreeView control. I was using specifically ..GetNodeFromIndex(), SelectedNodeIndex and NodeData. All 3 of which are now giving errors is the new Asp.net TreeView. I'm found the Value property which replaces NodeData, but what about GetNodeFromIndex and SelectedNodeIndex. Are they just... gone!? :(
4
10024
by: tfsmag | last post by:
Okay, I have a project management app i'm writing and in the left hand menu i have a treeview control that is populated with each project... in child nodes under each project node I have an "edit" and a "delete" node. I have the functionality of the edit and delete working fine, my issue is now however that I cannot seem to find a way to add an "onclick" event that fires a confirm box. I've tried this method.. treenode.Text = "<a...
2
8887
by: hibaru | last post by:
Hi Is it possible to call a javascript function from a treeview controls OnSelectedNodeChanged event? Something similar to a OnClientClick event for buttons? I cant seem to find anyway to do this, any help appreciated Thanks
3
1644
by: RayK50 | last post by:
I am developing a web site in vb.net 2.0 using a master page, with a custom Treeview control populated by a database query. Clicking on a certain Treeview menu item opens a page with a 3rd-party viewer in a content placeholder, using a simple Response.Redirect on the TreeView1_SelectedNodeChanged event. Now, I need to call a javascript function (from the 3rd-party) to retrieve and load a drawing image into the viewer. As soon as I insert...
0
8823
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9530
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9363
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9312
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8237
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6793
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4593
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4864
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3300
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.