Element的扩展

源码如下:

public Element(string label, string id)
    : this()
{
    Label = label;
    Id = id;
}

public Element(string label, string id, string className)
    : this(label, id)
{
    Class = className;
}

public Element(string label, string id, bool isrequired, string className)
    : this(label, id, className)
{
    IsRequired = isrequired;
}

public Element(string label, string id, bool isrequired, string className, string customValidate)
    : this(label, id, isrequired, className)
{
    ValidateCustom = customValidate;
}

之前写法:

<input Element="@(_.Create(v => v.Code))" />

现在需求:当一个页面中有两个一样的Code时,那提交后默认会把两个值保存到一个Code变量中,并用逗号隔开,那如果值中有逗号呢?所以通过上面源码,可以换一种写法,给他不一样的字段名,这样不至于出现前面的问题。

<input Element="@(new Element("版本名称","Code1"))" />
<input Element="@(new Element("版本名称","Code2"))" />

猜你喜欢

转载自www.cnblogs.com/stickcsharp/p/12484427.html