How to use Javascript to add Treeview control

Discussion in 'ASP .Net Web Controls' started by Peter, Nov 2, 2005.

  1. Peter

    Peter Guest

    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=""#f1f1f1"" 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=""treeview""
    Src=""treeview.ascx"" %>")
    writer.Write(" <%@ Register TagPrefix=""iewc""
    Namespace=""Microsoft.Web.UI.WebControls""
    Assembly=""Microsoft.Web.UI.WebControls"" %>")

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

    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
    Peter, Nov 2, 2005
    #1
    1. Advertising

  2. Peter

    Joshua Mitts Guest

    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


    "Peter" <> wrote in message
    news:...
    > 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=""#f1f1f1"" 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=""treeview""
    > Src=""treeview.ascx"" %>")
    > writer.Write(" <%@ Register TagPrefix=""iewc""
    > Namespace=""Microsoft.Web.UI.WebControls""
    > Assembly=""Microsoft.Web.UI.WebControls"" %>")
    >
    > ...................................
    >
    > 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
    >
    Joshua Mitts, Nov 3, 2005
    #2
    1. Advertising

  3. Peter

    Peter Afonin Guest

    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" <> wrote in message
    news:eR%...
    > 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
    >
    >
    > "Peter" <> wrote in message
    > news:...
    > > 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=""#f1f1f1"" 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=""treeview""
    > > Src=""treeview.ascx"" %>")
    > > writer.Write(" <%@ Register TagPrefix=""iewc""
    > > Namespace=""Microsoft.Web.UI.WebControls""
    > > Assembly=""Microsoft.Web.UI.WebControls"" %>")
    > >
    > > ...................................
    > >
    > > 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
    > >

    >
    >
    Peter Afonin, Nov 3, 2005
    #3
  4. Joshua hope you understood Joshua's adviced?
    Hope you have gone through:- http://msdn.microsoft.com/workshop/
    webcontrols/overview/treeview.asp
    Patrick


    "Peter Afonin" <> wrote in message
    news:us$...
    > 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" <> wrote in message
    > news:eR%...
    > > 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
    > >
    > >
    > > "Peter" <> wrote in message
    > > news:...
    > > > 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=""#f1f1f1"" 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=""treeview""
    > > > Src=""treeview.ascx"" %>")
    > > > writer.Write(" <%@ Register TagPrefix=""iewc""
    > > > Namespace=""Microsoft.Web.UI.WebControls""
    > > > Assembly=""Microsoft.Web.UI.WebControls"" %>")
    > > >
    > > > ...................................
    > > >
    > > > 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
    > > >

    > >
    > >

    >
    >
    Patrick.O.Ige, Nov 3, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Peter
    Replies:
    3
    Views:
    749
    Patrick.O.Ige
    Nov 3, 2005
  2. tfsmag
    Replies:
    4
    Views:
    12,759
    tfsmag
    Aug 27, 2006
  3. Chad Scharf
    Replies:
    3
    Views:
    860
    Chad Scharf
    Oct 18, 2007
  4. tcncc

    Add control to TreeView

    tcncc, Apr 14, 2009, in forum: ASP .Net
    Replies:
    0
    Views:
    317
    tcncc
    Apr 14, 2009
  5. Ionutz
    Replies:
    2
    Views:
    522
    Ionutz
    Oct 23, 2005
Loading...

Share This Page