如何使用带有webforms c#的.fileinput()?

时间:2016-01-07 15:52:03

标签: javascript c# jquery html webforms

我在ASP.Net C#中有以下代码:

private void InicializaControleUpload()
{
    string  urlUpload = "UploadTelaHandler.ashx?numDetalhe=";
    int tamanhoUpload = Convert.ToInt32(this.appSettingsBLL.GetAppSetting("TAMANHO_UPLOAD").KeyValue);
    string js = "$('#file1').fileinput({";
        js += "uploadUrl: \"" + urlUpload + "\",";
        js += "uploadAsync: true,";
        js += "maxFileCount: 3,";
        js += "validateInitialCount: true,";
        js += "overwriteInitial: false,";
        js += "maxFileSize: " + (tamanhoUpload / 1024) + ",";
        js += "'allowedPreviewTypes': 'image',";
        js += "'previewFileType': 'image',";
        js += "'allowedFileExtensions': ['jpg','gif','png','bmp']";
        js += "});";
    js += System.Environment.NewLine;
    JavascriptBox.WriteJavascriptJquery(this.Page, this.GetType(), fileUploadClient", js);
}

public static void WriteJavascriptJquery(Page page, Type type, string key, string script)
{
    string scriptComJquery = "$(function() {" + script + "});";
    ScriptManager.RegisterStartupScript(page, type, key, scriptComJquery, true);
}
<div class="form-group">
    <label class="control-label">Anexar captura de tela caso necessário</label>
    <input id="file1" type="file" multiple class="btn btn-default btn-xs" />                     
</div>

这是我实现加载图片的方式,但在上传文件时显示此错误:

  

&#34; NameofFile&#34; .jpg:[object Object]

有人可以帮助我吗?

0 个答案:

没有答案