Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I use id's of HTML elements in another sub when they are created from server-side code?
    text
    copied!<p>I have a table that I'm creating in code behind with the final column containing a HTML checkbox with runat="server".</p> <p>The code I'm using to do this is:</p> <pre><code> Do While reader.HasRows Do While reader.Read Dim tNewRow As New HtmlTableRow Dim cellSKU, cellDESCR, cellDept1, cellDeptGrp1, cellDeptRng1, cellStand, cellBoard, cellSelect As New HtmlTableCell cellSKU.InnerHtml = "&lt;a href='edit.aspx?edit=" &amp; reader("SKUN") &amp; "'&gt;" &amp; reader("SKUN") &amp; "&lt;/a&gt;" cellDESCR.InnerText = reader("DESCR") cellDept1.InnerText = reader("DPT1") cellDeptGrp1.InnerText = reader("GRP1") cellDeptRng1.InnerText = reader("RNG1") cellBoard.InnerText = reader("BOARD") cellStand.InnerText = reader("STAND") cellSelect.InnerHtml = "&lt;input type='checkbox' id='selectedSKU' value='" &amp; reader("SKUN") &amp; "' runat='server' /&gt;" tNewRow.Cells.Add(cellSKU) tNewRow.Cells.Add(cellDESCR) tNewRow.Cells.Add(cellDept1) tNewRow.Cells.Add(cellDeptGrp1) tNewRow.Cells.Add(cellDeptRng1) tNewRow.Cells.Add(cellStand) tNewRow.Cells.Add(cellBoard) tNewRow.Cells.Add(cellSelect) tNewRow.Style.Add("border", "solid 1px #cccccc") skusTable.Rows.Add(tNewRow) Loop reader.NextResult() Loop </code></pre> <p>But I want to use the checkbox in another sub such as:</p> <pre><code>Protected Sub editSkus_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles editSkus.Click End Sub </code></pre> <p>Though I can't use selectedSKU.whatever as the checkbox doesn't exist on the page until the other section of code is run.</p> <p>Is there a way I can get around this or another way of doing things?</p> <p>Thanks in advance for any help.</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