• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3718
  • Last Modified:

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!
0
ThePrettyGeek
Asked:
ThePrettyGeek
  • 4
1 Solution
 
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
 
ThePrettyGeekAuthor Commented:
Increasing point value to hopefully grab attention
0
Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

 
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
 
magadesign_sviluppoCommented:
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
 
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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now