1
嗨,我有2個問題正在運行:圖像文件所需的屬性
我使用的是運行非常適合其他類型,如文本框,複選框等,但對於這一個它不工作
requiredif屬性[必填項(「DoYouAgree」,ErrorMessage =「請上傳圖片徽標。」)] [DisplayName(「Upload Logo」)] string imgfile {get;組; }從視圖
代碼:
@*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>
有誰知道解決的辦法???? – user207888 2013-03-25 21:18:14
我知道js文件驗證。它不是一個屬性,但它會做的工作 – 2013-03-25 22:02:59
謝謝我做了我的工作與JS – user207888 2013-03-26 15:57:21