vb.net add html to aspx page dynamically
<p>I have an aspx page with a sidebar on the left.
The sidebar shows from one to many tasks grouped by date.
I want to show a modal popup passing an ID when user clicks a task.
The sidebar is something like this:</p>
<blockquote>
<p><strong>01/09/2016</strong></p>
<ul>
<li>Go to the dentist</li>
<li>Meet with Anna</li>
</ul>
<p><strong>02/09/2016</strong></p>
<ul>
<li>blabla</li>
</ul>
<p><strong>03/09/2016</strong></p>
<ul>
<li>bla1</li>
<li>bla2</li>
<li>bla3</li>
</ul>
</blockquote>
<p>etc.</p>
<p>On page load I declare variables and query my database with this:</p>
<pre><code>    Dim elementoLi As String = &quot;&lt;li&gt;&lt;h2&gt;&lt;i class=&quot;&quot;fa fa-cog fa-fw&quot;&quot;&gt;&lt;/i&gt;XXX&lt;/h2&gt;&lt;a href=&quot;&quot;#&quot;&quot;&gt;YYY&lt;/a&gt;&lt;/li&gt;&quot;
                        Dim htmlTitle As String = &quot;&lt;div class=&quot;&quot;title&quot;&quot;&gt;
                                                     &lt;h1&gt;XXX&lt;/h1&gt;
                                                 &lt;/div&gt;&lt;div class=&quot;&quot;content&quot;&quot;&gt;&lt;ul&gt;YYY&lt;/ul&gt;&lt;/div&gt;&lt;br/&gt;&quot;
                        Dim htmlContent As String = &quot;&quot;
                        Dim htmlChiamateaperte As String = &quot;&quot;
                        Dim htmlfinale As String = &quot;&quot;    
    
Dim chiamateAperte = From statoRic In
                                            dbVulcano.StatoRic.Where(Function(s) s.RFStato &gt;= 11 And s.RFStato &lt;= 13 And s.Attuale = 1 And s.RFTecnico = rfTecnico)
                                         From richiesta In
                                            dbVulcano.Richieste.Where(Function(r) r.IDRic = statoRic.RFRic).DefaultIfEmpty()
                                         From cliente In
                                            dbVulcano.Clienti.Where(Function(c) c.IDCliente = richiesta.RFCliente).DefaultIfEmpty()
                                         Select statoRic.RFRic, statoRic.RFStato, statoRic.Attuale, richiesta.Descr, cliente.RagSociale, statoRic.DataAss, statoRic.Data, dataf = If(statoRic.DataAss.HasValue, statoRic.DataAss, statoRic.Data)
                                         Order By dataf Descending
</code></pre>
<p>Then I cycle to create the sidebar structure:</p>
<pre><code>For Each item In chiamateAperte
                Dim data1 = Format(item.dataf, &quot;dd/MM/yyyy&quot;)
                If htmlChiamateaperte.Contains(data1) = False Then
                    htmlChiamateaperte = htmlChiamateaperte &amp; Replace(htmlTitle, &quot;XXX&quot;, data1)
                    htmlContent = &quot;&quot;
                End If


                For Each item2 In chiamateAperte
                    Dim data2 = Format(item2.dataf, &quot;dd/MM/yyyy&quot;)
                    If data2 = data1 Then
                        Dim rags, desc As String
                        desc = UppercaseFirstLetter(item2.Descr)
                        rags = item2.RagSociale
                        htmlContent = htmlContent &amp; Replace(Replace(elementoLi, &quot;XXX&quot;, rags), &quot;YYY&quot;, desc)
                    End If

                Next

                htmlChiamateaperte = Replace(htmlChiamateaperte, &quot;YYY&quot;, htmlContent)

            Next

            divChiamateAperte.InnerHtml = &quot;&lt;h1&gt;CHIAMATE APERTE&lt;/h1&gt;&lt;br /&gt;&lt;br /&gt;&quot; &amp; htmlChiamateaperte
</code></pre>
<p>Basically I dinamically create a string that at the end is passed as html code. What I need is to add links in the &quot;elementoLi&quot; var so that, once the user click on the link, it opens a modal popup (and passes along an ID). How can I do that? Doesn't matter if I have to change all the code to create the structure. Thanks</p>
<p><strong>EDIT 1:</strong>
This is the structure I need:</p>
<pre><code>&lt;div class=&quot;panel&quot; runat=&quot;server&quot; id=&quot;divChiamateAperte&quot; autopostback=&quot;true&quot;&gt;
    &lt;h1&gt;CHIAMATE APERTE&lt;/h1&gt;&lt;br /&gt;&lt;br /&gt;
  &lt;div class=&quot;title&quot;&gt;&lt;h1&gt;dd/mm/yyyy&lt;/h1&gt;
  &lt;/div&gt;
  &lt;div class=&quot;content&quot;&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;h2&gt;&lt;i class=&quot;fa fa-cog fa-fw&quot;&gt;&lt;/i&gt; RAGIONE SOCIALE 1&lt;/h2&gt; &lt;a href=&quot;#&quot;&gt;Descrizione 1&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;h2&gt;&lt;i class=&quot;fa fa-cog fa-fw&quot;&gt;&lt;/i&gt; RAGIONE SOCIALE 2&lt;/h2&gt; &lt;a href=&quot;#&quot;&gt;Descrizione 2&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/div&gt;
  &lt;br /&gt;
    &lt;div class=&quot;title&quot;&gt;&lt;h1&gt;dd/mm/yyyy&lt;/h1&gt;
  &lt;/div&gt;
  &lt;div class=&quot;content&quot;&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;h2&gt;&lt;i class=&quot;fa fa-cog fa-fw&quot;&gt;&lt;/i&gt; RAGIONE SOCIALE 1&lt;/h2&gt; &lt;a href=&quot;#&quot;&gt;Descrizione 1&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;h2&gt;&lt;i class=&quot;fa fa-cog fa-fw&quot;&gt;&lt;/i&gt; RAGIONE SOCIALE 2&lt;/h2&gt; &lt;a href=&quot;#&quot;&gt;Descrizione 2&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
  &lt;/div&gt;
&lt;/div&gt;
</code></pre>
<p><strong>EDIT 2:</strong>
I made this example using the structure above and the repeater, but the problem I see to obtain the above (where the block made by div title to div content can be 1 to infinite) is that I need to repeat the repeater result from 1 to X (where x is the data read from db).</p>
<pre><code> &lt;%@ Page Language=&quot;VB&quot; AutoEventWireup=&quot;True&quot; %&gt;

&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;
    &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
    &lt;title&gt;Repeater Example&lt;/title&gt;
    &lt;script runat=&quot;server&quot;&gt;


        Sub Page_Load(Sender As Object, e As EventArgs)

            If Not IsPostBack Then
                Dim values As New ArrayList()

                values.Add(&quot;Apple&quot;)
                values.Add(&quot;Orange&quot;)
                values.Add(&quot;Pear&quot;)
                values.Add(&quot;Banana&quot;)
                values.Add(&quot;Grape&quot;)

                ' Set the DataSource of the Repeater. 
                Repeater1.DataSource = values
                Repeater1.DataBind()
            End If
        End Sub

    &lt;/script&gt;

&lt;/head&gt;
&lt;body&gt;

    &lt;h3&gt;Repeater Example&lt;/h3&gt;

    &lt;form id=&quot;form1&quot; runat=&quot;server&quot;&gt;

        &lt;b&gt;Repeater1:&lt;/b&gt;
        &lt;br /&gt;

        &lt;asp:Repeater ID=&quot;Repeater1&quot; runat=&quot;server&quot;&gt;

            &lt;HeaderTemplate&gt;
                &lt;div class=&quot;title&quot;&gt;
                    &lt;h1&gt;dd/mm/yyyy&lt;/h1&gt;
                &lt;/div&gt;
                &lt;div class=&quot;content&quot;&gt;
                    &lt;ul&gt;
            &lt;/HeaderTemplate&gt;

            &lt;ItemTemplate&gt;


                &lt;li&gt;
                    &lt;h2&gt;&lt;i class=&quot;fa fa-cog fa-fw&quot;&gt;&lt;/i&gt;&lt;%# Container.DataItem %&gt;&lt;/h2&gt;
                    &lt;a href=&quot;#&quot;&gt;Descrizione 1&lt;/a&gt;&lt;/li&gt;

            &lt;/ItemTemplate&gt;

            &lt;FooterTemplate&gt;
                &lt;/ul&gt;
             &lt;/div&gt;
            &lt;/FooterTemplate&gt;

        &lt;/asp:Repeater&gt;
        &lt;br /&gt;

    &lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>