文件上传在更新面板中不起作用 [英] File upload not working in update panel

查看:95
本文介绍了文件上传在更新面板中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



i希望使用文件上传控件上传图片。我正在使用更新面板。当我提交表单时,fileupload.hasfile返回false.how我能解决这个问题吗?

解决方案

只需将以下代码添加到您的应用程序中。

将使面板回复并最终文件上载控件将开始工作。 />

 <   asp:UpdatePanel     ID   =  UpdatePanel1    runat   =  server    UpdateMode   = 有条件的 >  
< 触发器 >
< asp:PostBackTrigger < span class =code-attribute> ControlID = Button1 / > ;
< / Triggers >


将按钮放入单独的UpdatePanel并在那里设置PostBack触发器

Ex:

 <   asp:updatepanel     id   =   up1    runat   =   server >  <   br    mode   =  hold    xmlns:asp   = #unknown    /  >  <   ContentTemplate  >  
< ; > < tr > < < span class =code-leadattribute> td >
< asp:按钮 ID = btnSubmit runat = server CssClass = tbutton OnClick = btnSubmit_Click 文字 = 提交 工具提示 = 点击此处提交 < span class =code-attribute> ValidationGroup = 保存 / > < / td >



 <   / tr  >  
< / table >
< / ContentTemplate >
< 触发器 >
< asp:PostBackTrigger ControlID = btnSubmit / >
< /触发器 >
< / asp:UpdatePanel >


试试这个 -



 Page.Form.Attributes.Add(  enctype 多部分/格式数据); 


Hi,
i want to upload a picture using file upload control.i am using update panel.when i am submitting the form,fileupload.hasfile returns false.how do i solve this?

解决方案

just add the following code into your application.
that will cuse the panel to postback and eventually the fileupload control will start working.

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="conditional">
 <Triggers>
  <asp:PostBackTrigger ControlID="Button1" />
 </Triggers>


Place the button into separate UpdatePanel and set the PostBack trigger there
Ex:

<asp:updatepanel id=""up1"" runat=""server"><br" mode="hold" xmlns:asp="#unknown" /><ContentTemplate>
 <table><tr> <td>
<asp:Button ID="btnSubmit" runat="server" CssClass="tbutton" OnClick="btnSubmit_Click"Text="Submit" ToolTip="Click here to Submit"                   ValidationGroup="Save" /> </td >


</tr>
 </table>
 </ContentTemplate>
 <Triggers>
 <asp:PostBackTrigger ControlID="btnSubmit" />
</Triggers>
 </asp:UpdatePanel>


try this -

Page.Form.Attributes.Add("enctype", "multipart/form-data");


这篇关于文件上传在更新面板中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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