【发布时间】:2015-08-04 16:06:03
【问题描述】:
我在表格的单元格中创建了一个文本框,我正在使用它来获取用户的输入并将其显示在网页上。但是,当用户在文本框内部单击时,我无法更改文本框的背景,通常我会为此使用简单的 CSS,但由于文本框位于表格单元格内,我似乎无法弄清楚如何做到这一点.关于如何解决这个问题的任何想法?
我有以下 VB 代码来生成和填充我的表。
VB
Protected Sub GenerateTable(noOfRows As Integer)
Dim table As Table
Dim row As TableRow
Dim cell As TableCell
Dim tb As TextBox
Dim lbl As Label
table = Table1
table.ID = "Table1"
For i As Integer = 1 To noOfRows Step 1
row = New TableRow()
For j As Integer = 0 To 1 Step 1
cell = New TableCell()
If j = 1 Then
tb = New TextBox()
tb.ID = "TextBoxRow_" & i & "Col_" & j
cell.Controls.Add(tb)
ElseIf j = 0 Then
lbl = New Label()
lbl.ID = "Label" & i
lbl.Text = "Volume " & i
cell.Controls.Add(lbl)
End If
row.Cells.Add(cell)
Next
table.Rows.Add(row)
Next
ViewState("RowsCount") = noOfRows
Session("RowsCount") = noOfRows
End Sub
HTML
<tr>
<td colspan="2">
<asp:Table class="Table1" ID="Table1" runat="server"></asp:Table>
<br />
<asp:Button ID="btnAddVolume" class="btnVolumeBreak" runat="server" Text="Add Volume Break"/>
</td>
</tr>
【问题讨论】: