从文本框中读取数据时出现错误,这里是XML代码:
<asp:Button ID="btnSearch" runat="server" Style="z-index: 100; left: 513px; position: absolute;
top: 340px" Text="Search" Width="188px"/>
<asp:TextBox ID="MyTB" runat="server" Style="z-index: 101; left: 365px; position: absolute;
top: 302px" Width="493px"/>
这里是我调用文本框“MyTB”从中读取数据的代码:
protected void btnSearch_Click(object sender, EventArgs e)
{
string text = MyTB.Text;
string[] textArr = text.Split(new char[] { ' ', '\n', ',' });
}
XML代码:
<div>
<asp:Button ID="btnSearch" runat="server" Style="z-index: 100; left: 513px; position: absolute;
top: 340px" Text="Search" Width="188px"/>
<asp:TextBox ID="MyTB" runat="server" Style="z-index: 101; left: 365px; position: absolute;
top: 302px" Width="493px"/>
</div>
答案 0 :(得分:0)
代码似乎是正确的。您可以检查页面的 designer.cs 文件,以确保它已定义MyTB,例如
protected global::System.Web.UI.WebControls.TextBox MyTB;