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

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!
ThePrettyGeekAsked:
Who is Participating?
 
magadesign_sviluppoConnect With a Mentor Commented:
hi,
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">
                                        <li>
                                            <a href="MyURL">Tab Text</a>
                                        </li>
                                    </asp:PlaceHolder>

Open in new window


and in code behind decide if show or hide PlaceHolder1 like
PlaceHolder1.Visible = true or false
0
 
dexion432Commented:
Do not use innerHTML, try to use the object model of the id, like this:

http://stackoverflow.com/questions/186918/c-how-to-change-html-elements-attributes

0
 
ThePrettyGeekAuthor Commented:
Something is just not clicking with this. I dont know if its my conversion of C# to vb.net or what but that tutorial is not ringing true with me.
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
ThePrettyGeekAuthor Commented:
Increasing point value to hopefully grab attention
0
 
ThePrettyGeekAuthor Commented:
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>
</ul
0
 
ThePrettyGeekAuthor Commented:
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,
Cristy


html code

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

            <li>

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

            </li>
</asp:placeholder>

VB Code
            lbl5.Text = "<a href=./NewPage.aspx>New Page</a>"
            ExtraTab1.Visible = True
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.