我正在使用Microsoft Visual Web Developer2010。我有一个使用以下代码的文本框(txtBoxInput):<input type="text" id="txtBoxInput"/>

我还有一个使用代码的aspn.net按钮(btnTest):

<asp:Button ID="btnTest" runat="server" onclick="Button1_Click" Text="Button"/>


以及btnTest事件中的代码:

protected void Button1_Click(object sender, EventArgs e)
{
    string test = txtBoxInput.Value = "test123";
}


但是,未检测到txtBoxInput控件。
有没有一种方法可以编写此C#/ aspn.net代码将此字符串(测试)放入txtBox.Value中。
谢谢

最佳答案

您需要添加runat="server"。否则,输入在服务器端将不可见,您将需要访问通过Request.Form集合发布的值。

<input runat="server" type="text" id="txtBoxInput"/>

09-12 20:39