Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>What your full code shows is that your building a massive string of HTML. This is fine for some <em>smaller</em> situations, but your code is clearly getting quite big now, and I would suggest you change this approach.</p> <p>I would recommend that you declare web control equivalents, such as:</p> <pre><code>new HtmlGenericControl("div") instead of &lt;div&gt;&lt;/div&gt; </code></pre> <p>OR</p> <pre><code>new HtmlAnchor() OR new LinkButton() instead of &lt;a&gt;&lt;/a&gt; </code></pre> <p>In the example of a tree structure the HTML may look like this:</p> <pre><code>&lt;ul&gt; &lt;li&gt; &lt;a href="root.htm"&gt;ROOT&lt;/a&gt; &lt;ul&gt; &lt;li&gt; &lt;a href="levelone"&gt;LEVEL 1&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre> <p>To generate this in code you would do something similar to:</p> <pre><code>'Menu Holder Dim treeStruct As HtmlGenericControl("ul") 'Root Dim branch As HtmlGenericControl("li") Dim branchItem as HtmlAnchor("a") 'Level 1 Dim subLevel As HtmlGenericControl("ul") Dim subBranch As HtmlGenericControl("li") Dim subBranchItem as HtmlAnchor("a") 'Setup Level 1 subBranchItem.InnerText = "LEVEL 1" subBranchItem.Href = "levelone" subBranch.Controls.Add(subBranchItem) subLevel.Controls.Add(subBranch) 'Setup Root branchItem.InnerText = "ROOT" branchItem.Href = "root.htm" 'Add Link To Root branch.Controls.Add(branchItem) 'Add Sub Branch To Root branch.Controls.Add(subLevel) treeStruct.Controls.Add(branch) </code></pre> <p><strong>Important</strong> The code above is just for examples sake, ideally you would separate the functionality into functions for branch creation and then loop through your elements with your for loop.</p> <p>You will also notice that I have used an <code>&lt;UL&gt;</code> instead of <code>&lt;DIV&gt;</code> as I would consider a tree structure to be an un-ordered list. Plus, you will also get the styling benefit from this more ridged structure.</p> <p>I hope this helps</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload