Cannot get inner content of UL because the contents are not literal.

Posted on 2011-05-01
Last Modified: 2012-05-11
Im using an unorder list <UL> with some css formatting to put them into tabs at the top of my page for navigation. I want to dynamically add another tab to the list when a user is logged in. I thought I could do this simly by adding the runat="server" command to the UL and then IDName.InnerHTML +="<li><a href=MyURL>Tab Text</a></li>" to an if statement for when the user is logged in to the vb code. but when I get to the page and it tries to run the code I get the error.

Cannot get inner content of tabs because the contents are not literal.

tabs being the ID of the UL

I searched around a bit and found some similar questions reguarding divs but nothing that I could get to work. Please help!
Question by:ThePrettyGeek
    LVL 5

    Expert Comment

    Do not use innerHTML, try to use the object model of the id, like this:


    Author Comment

    Something is just not clicking with this. I dont know if its my conversion of C# to or what but that tutorial is not ringing true with me.

    Author Comment

    Increasing point value to hopefully grab attention

    Author Comment

    I recently tried using an <asp:bulletedlist....> and this almost worked except for because these are he links at the top of the page I need hrefs in there as well and is inturpreting the < and the > as &lt; and &gt;

    example HTML
    <asp:bulletedlist id="testid" runat="server" bulletstyle="notset"></asp:bulletedlist>

    example VB
    testid.items.add("<a href=some URL>Text</a>")
    testid.items.add("<a href=some URL>Text</a>")
    testid.items.add("<a href=some URL>Text</a>")
    testid.items.add("<a href=some URL>Text</a>")

    what I get in the source during runtime is
    <ul id="testid">
    <li>&lt;a href=some URL&gt;Text&lt;/a&gt;</li><li>&lt;a href=some URL&gt;Text&lt;/a&gt;</li><li>&lt;a href=some URL&gt;Text&lt;/a&gt;</li><li>&lt;a href=some URL&gt;Text&lt;/a&gt;</li>
    LVL 3

    Accepted Solution

    if the problem iz just showing or hiding one <li>
    the smartest solution could be nesting the html of it into PlaceHolder
                                        <asp:PlaceHolder ID="PlaceHolder1" runat="server" Visible="false">
                                                <a href="MyURL">Tab Text</a>

    Open in new window

    and in code behind decide if show or hide PlaceHolder1 like
    PlaceHolder1.Visible = true or false

    Author Closing Comment

    Thank you Magadesign sviluppo,
    That worked wonderfully. I did it slightly different by using an asp:label and Ill enter my slightly modified code in a sec but I knew it had to be something stupid simple I wasn't even considering.

    Thanks Again,

    html code

    <asp:placeholder ID="ExtraTab1" runat="server" Visible="false">


                      <asp:Label ID="lbl5" runat="server"></asp:Label>


    VB Code
                lbl5.Text = "<a href=./NewPage.aspx>New Page</a>"
                ExtraTab1.Visible = True

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Suggested Solutions

    Title # Comments Views Activity
    Query datatable in LINQ 6 27
    Combine two columns 3 31
    Unable to get blue colour in background of using HTML 6 45
    Xamarin 10 18
    Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
    This demonstration started out as a follow up to some recently posted questions on the subject of logging in: and…
    Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
    The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now