无法使用 VB.NET 在 MVC 2 中获取实体元数据
我尝试使用元数据通过 MVC2、LINQ to SQL 和 VB.NET 进一步定义我的实体对象。以下是有问题的两段主要代码:
<HiddenInput(DisplayValue:=False)> _
<Column(IsPrimaryKey:=True, IsDbGenerated:=True, AutoSync:=AutoSync.OnInsert)> _
Public Property ItemID As Integer
Get
Return _itemID
End Get
Set(value As Integer)
_itemID = value
End Set
End Property
<DataType(DataType.MultilineText)> _
<Column()> _
Public Property Description As String
Get
Return _description
End Get
Set(value As String)
_description = value
End Set
End Property
这是我的视图的代码:
<div class="editor-label">
<%: Html.LabelFor(Function(model) model.ItemID) %>
</div>
<div class="editor-field">
<%: Html.TextBoxFor(Function(model) model.ItemID) %>
<%: Html.ValidationMessageFor(Function(model) model.ItemID) %>
</div>
<div class="editor-label">
<%: Html.LabelFor(Function(model) model.Description) %>
</div>
<div class="editor-field">
<%: Html.TextBoxFor(Function(model) model.Description) %>
<%: Html.ValidationMessageFor(Function(model) model.Description) %>
</div>
对于第一个示例,我的“创建视图”应该在生成的 html 中呈现“隐藏”的输入标记。在第二个示例中,由于元数据和元数据,我的创建视图应该呈现更大的输入文本字段以进行描述。然而,这两种情况都没有发生。
我首先想到的是,也许我在 VB.NET 中定义元数据的语法不恰当。我定义元数据的所有示例都是用 C# 编写的...我在 VB.NET 中可以找到绝对零个示例。请帮忙。
I am trying to use metadata to further define my entity objects using MVC2, LINQ to SQL, and VB.NET. Here are the two main pieces of code in question:
<HiddenInput(DisplayValue:=False)> _
<Column(IsPrimaryKey:=True, IsDbGenerated:=True, AutoSync:=AutoSync.OnInsert)> _
Public Property ItemID As Integer
Get
Return _itemID
End Get
Set(value As Integer)
_itemID = value
End Set
End Property
<DataType(DataType.MultilineText)> _
<Column()> _
Public Property Description As String
Get
Return _description
End Get
Set(value As String)
_description = value
End Set
End Property
Here's the code for my view:
<div class="editor-label">
<%: Html.LabelFor(Function(model) model.ItemID) %>
</div>
<div class="editor-field">
<%: Html.TextBoxFor(Function(model) model.ItemID) %>
<%: Html.ValidationMessageFor(Function(model) model.ItemID) %>
</div>
<div class="editor-label">
<%: Html.LabelFor(Function(model) model.Description) %>
</div>
<div class="editor-field">
<%: Html.TextBoxFor(Function(model) model.Description) %>
<%: Html.ValidationMessageFor(Function(model) model.Description) %>
</div>
For the first example, my Create View is supposed to render the input tag 'hidden' in the resulting html. In the second example, my Create View is supposed to render a larger input text field for description, because of the metadata and the metadata, respectively. However, neither occurs.
The first thing that comes to mine is that maybe I am defining metadata in VB.NET syntactically inappropriately. All of my examples of defining metadata are in C#... I can find absolutely zero examples in VB.NET. Please help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Html.TextBoxFor()
始终呈现可见的文本框。因此得名。 :)要根据属性使用不同类型的编辑器,请改用
Html.EditorFor()
。Html.TextBoxFor()
always renders a visible text box. Hence the name. :)To have a different kind of editor based on the attributes, use
Html.EditorFor()
instead.