WebControl.TextBox embedded in an HTML table

G

Glenn Thimmes

I have a few textboxes inside a client side HTML table. When I type text in
them and click a button server control that causes a post back to the
server, the textboxes contain empty strings in the button click event. If I
have a textbox outside the table, however, it does contain test during the
button click event.

Is there a reason why the textboxes do not function properly inside an HTML
table?

Thanks,
Glenn Thimmes
 
K

Ken Cox [Microsoft MVP]

Hi Glenn,

I can't reproduce your problem in my code (see below). Could you post the
troublesome code so we can investigate it?

Private Sub Button1_Click _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Button1.Click
Dim sb As New System.Text.StringBuilder
sb.Append(TextBox1.Text & "<br>")
sb.Append(TextBox2.Text & "<br>")
sb.Append(TextBox3.Text & "<br>")
sb.Append(TextBox4.Text & "<br>")
sb.Append(TextBox5.Text & "<br>")
Label1.Text = sb.ToString
End Sub

<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="300"
border="1">
<TR>
<TD>
<asp:TextBox id="TextBox1" runat="server">TextBox1</asp:TextBox></TD>
<TD>
<asp:TextBox id="TextBox2" runat="server">TextBox2</asp:TextBox></TD>
<TD></TD>
</TR>
<TR>
<TD>
<asp:TextBox id="TextBox3" runat="server">TextBox3</asp:TextBox></TD>
<TD></TD>
<TD></TD>
</TR>
<TR>
<TD>
<asp:TextBox id="TextBox4" runat="server">TextBox4</asp:TextBox></TD>
<TD></TD>
<TD>
<asp:TextBox id="TextBox5" runat="server">TextBox5</asp:TextBox></TD>
</TR>
</TABLE>
<P>
<asp:Button id="Button1" runat="server" Text="Button"></asp:Button></P>
<P>
<asp:Label id="Label1" runat="server"></asp:Label></P>

Ken
Microsoft MVP [ASP.NET]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top