alone.m2a
شنبه 28 فروردین 1395, 07:11 صبح
با سلام من روی یه فرم ساز دارم کار میکنم مشکلی که دارم نمیتونم فایل رو داخل کنترلر بخونم فقط نام و پسوند فایل فرستاده میشه
اکشن:
public virtual ActionResult ShowForm(IEnumerable<FormFieldType> values)
{{
ویو:
if ((FormFieldsType)Model.ElementAt(i).Type == FormFieldsType.File) {
<input type="hidden" name="[@i].FieldName" value="@Model.ElementAt(i).FieldName" />
<input type="hidden" name="[@i].FormId" value="@Model.ElementAt(i).FormID" />
<div class="form-group">
<div class="col-md-9" dir="rtl">
<div class="form-inline">
<input id="u1p" class="form-control fc" type="file" name="[@i].Value" />
<input type="button"id="up" name="آپلود" value="آپلود" class="btn btn-default" />
<input type="button" name="حذف" value="حذف" class="btn btn-default" />
</div>
</div>
<div class="col-md-3" dir="rtl">
<div>@Model.ElementAt(i).Title</div>
</div>
</div>
}
مدل:
public partial class FormFieldType {
public int ID { get; set; }
public int FormID { get; set; }
public bool? Required { get; set; }
public int? Type { get; set; }
[StringLength(150)]
public string FieldName { get; set; }
[StringLength(150)]
public string Title { get; set; }
public int GroupID { get; set; }
public string TypeData { get; set; }
[NotMapped]
public string Value { get; set; }
public virtual Form Form { get; set; }
}
لیست نوع ها:
public enum FormFieldsType {
Int = 1,
Number = 2,
FarsiDate = 3,
EnglishDate = 4,
File = 5,
Image = 6,
List = 7,
Text = 8
}
اکشن:
public virtual ActionResult ShowForm(IEnumerable<FormFieldType> values)
{{
ویو:
if ((FormFieldsType)Model.ElementAt(i).Type == FormFieldsType.File) {
<input type="hidden" name="[@i].FieldName" value="@Model.ElementAt(i).FieldName" />
<input type="hidden" name="[@i].FormId" value="@Model.ElementAt(i).FormID" />
<div class="form-group">
<div class="col-md-9" dir="rtl">
<div class="form-inline">
<input id="u1p" class="form-control fc" type="file" name="[@i].Value" />
<input type="button"id="up" name="آپلود" value="آپلود" class="btn btn-default" />
<input type="button" name="حذف" value="حذف" class="btn btn-default" />
</div>
</div>
<div class="col-md-3" dir="rtl">
<div>@Model.ElementAt(i).Title</div>
</div>
</div>
}
مدل:
public partial class FormFieldType {
public int ID { get; set; }
public int FormID { get; set; }
public bool? Required { get; set; }
public int? Type { get; set; }
[StringLength(150)]
public string FieldName { get; set; }
[StringLength(150)]
public string Title { get; set; }
public int GroupID { get; set; }
public string TypeData { get; set; }
[NotMapped]
public string Value { get; set; }
public virtual Form Form { get; set; }
}
لیست نوع ها:
public enum FormFieldsType {
Int = 1,
Number = 2,
FarsiDate = 3,
EnglishDate = 4,
File = 5,
Image = 6,
List = 7,
Text = 8
}