我正在尝试获取表中的Textbox
的值。该表也在另一列的一行内。我正在尝试使用TextBox_UN.Text
(nameofthetextbox.Text
)来获取它,但是它错误地说这个名称不存在。请有人就此提出建议。我真的很感激帮助。
谢谢
LoginForm.aspx :
<body>
<form id="form1" runat="server">
<div>
<table cellpadding="0" cellspacing="0" class="styleTable1">
<tr>
<td class="stylerow3">
<table align="center"
style="border-left-style: outset; border-left-width: 3px; border-right: 3px outset #C0C0C0; border-top-style: outset; border-top-width: 3px; border-bottom: 3px outset #C0C0C0" >
<tr>
<td style="color: #0066FF"></td>
<td >
<span style="font-size: xx-large; color: #0066CC; text-align: left;">LOGIN</span>
</td>
<td></td>
</tr>
<tr>
<td class="style1" style="color: #0066FF">Username</td>
<td class="style1">
<asp:TextBox ID="TextBox_UN" runat="server" Width="180px"> </asp:TextBox>
</td>
<td class="style1">
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="TextBox_UN" ErrorMessage="Please enter Username"
ForeColor="#666666"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style4" style="color: #0066FF">Password</td>
<td>
<asp:TextBox ID="TextBox_PW" runat="server" TextMode="Password" Width="180px"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="TextBox_PW" ErrorMessage="Please enter Password"
ForeColor="#666666"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td ></td>
<td>
<asp:Button ID="B_Login" runat="server" onclick="B_Login_Click" Text="Submit" Width="78px" />
</td>
<td style="height: 30px"></td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</form>
</body>
LoginForm.aspx.cs :
string checkuser = "select count(*) from Table1 where UserName='" + ***TextBox_UN.Text*** + "'";
答案 0 :(得分:0)
为什么不使用其ID引用对象? 文本框的位置并不重要。
背后的代码上提供了相应的对象