我正在使用 Microsoft Visual Web Developer 2010。我有一个文本框 (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"/>
关于c# - 通过按钮(asp.net)将字符串输入textbox.value(JavaScript),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18516180/