选择下拉菜单后,文件上传控件保留空白 [英] file upload control geeting blank after selecting dropdown

查看:82
本文介绍了选择下拉菜单后,文件上传控件保留空白的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用fileupload控件,但在选择下拉菜单后却变得空白,仍然使用upadate面板

I am using fileupload control, but its getting blank after slecting dropdown,still i using upadate panel

推荐答案

如果要在updatepanel中保留文件上传控件,请尝试在Page_Load下添加Page.Form.Attributes.Add("enctype","multipart/form-data"),并为上传按钮添加一个PostBackTrigger.

但是如果您不想这样做,只需将ur fileupload控件移到面板外,这样当下拉列表执行回发操作时,您的fileupload不会受到影响.出于某种安全原因,Microsoft实现的一部分是在页面回发时,需要重置ur fileupload控件中的值.

请在这里
文件上传控制


后面的代码
If you want to retain your fileupload control inside updatepanel try adding Page.Form.Attributes.Add("enctype", "multipart/form-data") under Page_Load and have a PostBackTrigger for the upload button.

but if you don''t want to do that just move ur fileupload control outside the panel so that when the dropdown performs a postback your fileupload will not be affected. part of implementation of microsoft for some security reason is that when page postback the values in ur fileupload control needs to reset.

refer here
fileupload control


code behind
protected void Page_Load(object sender, EventArgs e)
{
    this.Page.Form.Attributes.Add("enctype", "multipart/form-data");
}



在ui



in ui

<asp:updatepanel xmlns:asp="#unknown">
        <contenttemplate>
            ......
        </contenttemplate>
        <triggers>
            <asp:postbacktrigger controlid="btnUpload" />
        </triggers>
    </asp:updatepanel>


这篇关于选择下拉菜单后,文件上传控件保留空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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