初始化asp.net中的html控件

1 asp.net

如果我有一个html输入"<input id="score1" type="text" value=""/>"并希望在c#页面加载时初始化它,但我不想使用asp控件.我该怎么办?

谢谢

Mat*_*ves 5

您可以使用runat ="server"来使用服务器端纯HTML控件.

例如:


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

// ...and then in the code-behind...

myTextBox.Value = "harbl";
Run Code Online (Sandbox Code Playgroud)

  • ...而对于记录,这些通常在ASP.NET领域称为"混合控件".不完全是HTML控件,不是Web控件. (2认同)
  • 我从未见过他们被称为混合控制.他们一直都是HTML控件. (2认同)