【发布时间】:2013-03-15 11:28:20
【问题描述】:
您好,我遇到了 2 个问题:
-
我正在使用 requiredif 属性,该属性非常适合其他类型,如文本框、复选框等,但对于这个它不起作用
[RequiredIf("DoYouAgree", ErrorMessage = "请上传图片徽标。")] [DisplayName("上传徽标")] 字符串 imgfile { 获取;放; }
视图代码:
@*Browse File*@
<div class="clear"></div>
<div class="editor-label grid_2">
<br /><br /> @Html.LabelFor(model => model.imgfile):
</div>
<div style="margin-top:38px;" class="grid_2">
<input type="file" name="imgfile" id="imgfile" />
</div>
<div class="editor-label1 grid_3" style="margin-top:40px;margin-left:80px;" >
Max file size 299*299 px or 44KB
</div>
<br /><br /><br /><br />
<div class="grid_3 error long" style="margin-left:10px;">
@Html.ValidationMessageFor(model => model.imgfile)
</div>
<br />
为什么它不适合这个。
- 我有其他文件只需要必需的属性,但是当我点击我的按钮而不上传图片时它也不起作用
提前致谢!
[Required(ErrorMessage = "Please upload screenshot image.")]
[DisplayName("Screen Shots")]
public string ssimgfile { get; set; }
查看:
div style="margin-top:38px; margin-bottom:20px;" class="grid_2">
<input type="file" name="ssimgfile" id="ssimgfile" />
<div class="grid_3 error long" style="margin-left:4px;">
@Html.ValidationMessageFor(model => model.ssimgfile)
</div>
</div>
【问题讨论】:
-
有谁知道解决办法???
-
我知道文件的 js 验证。它不是一个属性,但它会完成这项工作
-
感谢我用 JS 完成了我的工作
标签: asp.net-mvc razor