English 中文(简体)
两个名称相同的领域
原标题:Two fields with the same name

我有一门“个人”和“企业”模式。 我的问题是,这两种模式都有一种称为“电子邮件”的财产,而具有约束力的模式无法区分这两种财产。

我读到,<代码>[Bind(Prefix = ......)用于解决这一问题,但我未能看到如何实现这一目标的简明例子。

public class BusinessFormViewModel
{
    public Business Business { get; set; }
    public ContactPerson ContactPerson { get; set; }

    public BusinessFromView(Business business, ContactPerson contactPerson)
    {
        Business = business;
        ContactPerson = contactPerson;
    }
}

我如何利用“宾德”办法解决这一问题?

最佳回答

我认为,如果所张贴的形式要素包含在名称中,那么约束力将适当完成。 这就是模版的助手(即编版)如何使控制成为可能,我所nes的视像仪受到适当约束。 例如,在你看来,你的看法将构成这样的内容:

...
<input type="text" name="Business.Email" value="<%=this.Model.Business.Email %>" />
...
<input type="text" name="ContactPerson.Email" value="<%=this.Model.ContactPerson.Email %>" />
...

或者,使用模版助手(在2级):

...
<%= Html.TextBoxFor(m => m.Business.Email) %>
...
<%= Html.TextBoxFor(m => m.ContactPerson.Email) %>
...

你们的控制者只是想做生意。 表格二

public BusinessFromView(BusinessFormViewModel businessForm)
{
    Business = businessForm.Business;
    ContactPerson = businessForm.ContactPerson;
}
问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签