【发布时间】:2018-07-21 15:57:58
【问题描述】:
我有一个班级。
public class Graf
{
public List<Point> first { get; set; }
public List<Point> second { get; set; }
}
这个类包含列表
public class Point
{
public int x { get; set; }
public int y { get; set; }
public Point(int x, int y)
{
this.x = x;
this.y = y;
}
}
我需要在 index.cshtml 中的 Graf 类中添加一个 Point:
@model WebApplication2.Models.Graf
<table>
<tr>
<td></td>
<td>
<div class="item">
<label>Y</label>
<input name="Y11" value="@Model.first" /> --------??
</div>
</td>
</tr>
</table>
<input type="submit" value="Send" />
但我现在不知道如何输入 Graf 类点?
我该怎么做?
【问题讨论】:
-
您只需将对象从客户端传递到控制器,然后将此对象添加到您的列表中:
first.Add(point) -
好的,我有在控制器中添加点的方法,但是如何从客户端调用此方法?例如,我有 以及我必须如何从 index.csHtml 中放置类 Point。谢谢!
标签: asp.net visual-studio razor asp.net-core-mvc