电子邮件附件不再工作自定义样式化ASP:文件上传现场 [英] Email Attachment No Longer Working As Custom Styled ASP:FileUpload Field

查看:126
本文介绍了电子邮件附件不再工作自定义样式化ASP:文件上传现场的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个asp.net应用程序,它允许一个文件上传和我有这个工作正常,但现在我已经定制风格我的文件上传领域它不再工作,我无法弄清楚如何得到它再次合作我新风格的领域。

I have an asp.net application which allows a file upload and I had this working correctly but now I have custom styled my file upload field it's no longer working and I can't figure out how to get it working again with my new styled field.

旧的HTML

<div class="form-group">
    <asp:Label ID="Label3" class="col-md-3 control-label" runat="server" Text="Upload"></asp:Label>
    <div class="col-md-3">
        <asp:FileUpload ID="fuAttachment" runat="server" class="fileupload"></asp:FileUpload>
    </div>
</div>

OLD code背后

    var file = fuAttachment.PostedFile;
    if (file != null && fuAttachment.PostedFile.FileName != "")
    {
        var content = new byte[file.ContentLength];
        file.InputStream.Read(content, 0, content.Length);
        Session["FileContent"] = content;
        Session["FileContentType"] = file.ContentType;
        Session["File"] = fuAttachment.FileName;
        Session["AttachmentProvided"] = "Yes";
    }

新的HTML

    <div class="fileinput fileinput-new input-group" data-provides="fileinput">
        <div class="form-control" data-trigger="fileinput" style="background-color: #ededed">
            <span class="fileinput-filename"></span>
        </div>
        <span class="input-group-addon btn btn-default btn-file">
            <span class="fileinput-new">
                <span class="glyphicon glyphicon-folder-open" title="Click to select a file."></span>
            </span>
            <span class="fileinput-exists">
                <span class="glyphicon glyphicon-folder-open" title="Click to change the selected file."></span>
            </span>
            <input type="file" name="...">
        </span>
        <a href="#" class="input-group-addon btn btn-default fileinput-exists" data-dismiss="fileinput">
            <span class="glyphicon glyphicon-remove" title="Remove selected file."></span>
        </a>
    </div>

我需要在我的会话存储,因为这将填充另一个页面,所以我需要身后,我有类似code

I need to store in my session as this populates another page so I need similar code behind as I had

推荐答案

编辑文件,输入:

<input type="file" id="fuAttachment" runat="server" />

现在您使用fuAttachment从codebehind访问上传的文件。

Now you use fuAttachment from codebehind for access uploaded file.

请注意:如果 =服务器属性丢失你不能够控制从codebehind此输入

Note: If runat="server" attribute is missing you don't able to control this input from codebehind.

这篇关于电子邮件附件不再工作自定义样式化ASP:文件上传现场的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆