Ste*_*Toe 0 c# asp.net-core blazor
在我正在构建的 blazor 应用程序中,我有以下 cshtml 代码,其中包含一个<input>供用户输入姓名的元素。我希望能够将输入元素的值绑定到 blazor 页面的 c# 函数部分中的 Name 属性。
我该怎么做呢?
我的代码如下:
@page "/nameUpload"
<p>
//This is the input element that I would like to bind
Enter your name: <input type="text" ><br />
</p>
@functions {
//This is the property that I want to bind the input to
private string Name { get; set; } = "";
}
Run Code Online (Sandbox Code Playgroud)
使用@bind带有input.
@page "/nameUpload"
<p>
@* This is the input element that I would like to bind *@
Enter your name: <input type="text" @bind(name) />
<br />
</p>
@functions {
@* This is the property that I want to bind the input to *@
string name;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2788 次 |
| 最近记录: |