ASP.NET MVC 嵌套对象的字段命名约定
我正在使用 ASP.NET MVC 1.0。 我正在创建一个视图来创建以下类的新对象
public class ClassOne
{
public string Name {get; set;}
public string Id {get; set; }
public CaptionItem Caption {get; set;}
}
public class CaptionItem
{
public string CaptionSet {get; set;}
public string Text {get; set;}
}
该视图将具有用于输入名称、Id 和标题文本的字段。提交表单后,ClassOne 对象被发送到控制器,该控制器应该将该对象保留在数据库中。
问题是;应该使用什么命名约定,以便我可以将对象发送到控制器,因为
public ActionResult SaveObject(ClassOne objectToSave)
挑战是标题对象
I am using ASP.NET MVC 1.0.
I am creating a view to Create a new object of the following class
public class ClassOne
{
public string Name {get; set;}
public string Id {get; set; }
public CaptionItem Caption {get; set;}
}
public class CaptionItem
{
public string CaptionSet {get; set;}
public string Text {get; set;}
}
The view will have fields to input Name, Id and the Text of the caption. On submitting the form the ClassOne object is sent to the controller which is supposed to persist the object in the database.
The question is; what should be the naming conventions used so that I can send the object to the controller as
public ActionResult SaveObject(ClassOne objectToSave)
The challenge is the Caption object
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你是对的,要进入文本字段,你必须输入 Caption.Text :)
you're right, to get to Text field you have to type Caption.Text :)