parsdarab
سه شنبه 29 دی 1394, 03:15 صبح
سلام شب بخیر
من یک helper به صورت زیر نوشتم
@helper imageUploader(string fieldImage, string fieldStr, string fieldPriview){
<input type="file" id='@fieldImage' />
<input type="hidden" id='@fieldStr' />
<div id="@fieldPriview"></div>
<style>
#@fieldPriview {
width: 90px;
height: 90px;
background-position: center center;
background-size: cover;
-webkit-box-shadow: 0 0 1px 1px rgba(0, 0, 0, .3);
display: inline-block;
}
</style>
<script>
$(function () {
$("#@fieldImage").on("change", function () {
var files = !!this.files ? this.files : [];
if (!files.length || !window.FileReader) return; // no file selected, or no FileReader support
if (/^image/.test(files[0].type)) { // only image file
var reader = new FileReader(); // instance of the FileReader
reader.readAsDataURL(files[0]); // read the local file
reader.onloadend = function () { // set image data as background of div
$("#@fieldPriview").css("background-image", "url(" + this.result + ")");
$("#@fieldStr").val(this.result);
//$("#texens").val("tinkumaster");
}
}
});
});
</script>
}
که بر اساس پارامترهای ورودی جندتا input میسازه
طرز استفاده:
@Helpers.imageUploader("PersonelImage", "PersonelImageStr", "fieldPriview")
خوب حالا مشکل اینجاست که یکی از این input ها باید bind بشه وقتی داده ها به سمت سرور post میشن
هر کاری کردم نشد اسم کلاسو توی اکشنه نوشتم نشد
یه متغیر جدا تعریف کردم نشد
از request استفاده کردم نشد
public ActionResult Create(BasePersonel model, string PersonelImageStr) {
var f = Request.Form["PersonelImageStr"];}
این کد قبل از اینکه به helper بره درست کار میکره و داده ها در کلاس و متغیر bind میشده
وقتی با فایر باگ هم چک می کنم دسته
138493
لطفا راهنمایی بفرمایید
ممنونم
من یک helper به صورت زیر نوشتم
@helper imageUploader(string fieldImage, string fieldStr, string fieldPriview){
<input type="file" id='@fieldImage' />
<input type="hidden" id='@fieldStr' />
<div id="@fieldPriview"></div>
<style>
#@fieldPriview {
width: 90px;
height: 90px;
background-position: center center;
background-size: cover;
-webkit-box-shadow: 0 0 1px 1px rgba(0, 0, 0, .3);
display: inline-block;
}
</style>
<script>
$(function () {
$("#@fieldImage").on("change", function () {
var files = !!this.files ? this.files : [];
if (!files.length || !window.FileReader) return; // no file selected, or no FileReader support
if (/^image/.test(files[0].type)) { // only image file
var reader = new FileReader(); // instance of the FileReader
reader.readAsDataURL(files[0]); // read the local file
reader.onloadend = function () { // set image data as background of div
$("#@fieldPriview").css("background-image", "url(" + this.result + ")");
$("#@fieldStr").val(this.result);
//$("#texens").val("tinkumaster");
}
}
});
});
</script>
}
که بر اساس پارامترهای ورودی جندتا input میسازه
طرز استفاده:
@Helpers.imageUploader("PersonelImage", "PersonelImageStr", "fieldPriview")
خوب حالا مشکل اینجاست که یکی از این input ها باید bind بشه وقتی داده ها به سمت سرور post میشن
هر کاری کردم نشد اسم کلاسو توی اکشنه نوشتم نشد
یه متغیر جدا تعریف کردم نشد
از request استفاده کردم نشد
public ActionResult Create(BasePersonel model, string PersonelImageStr) {
var f = Request.Form["PersonelImageStr"];}
این کد قبل از اینکه به helper بره درست کار میکره و داده ها در کلاس و متغیر bind میشده
وقتی با فایر باگ هم چک می کنم دسته
138493
لطفا راهنمایی بفرمایید
ممنونم