如何编写fileupload&的代码文本框。 [英] How to write a code for fileupload & textbox.

查看:80
本文介绍了如何编写fileupload&的代码文本框。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友们,



我有第一个图片上传(文件上传)和第二个TextBox,现在我的问题是每当点击提交按钮时没有数据在文本框中,它将显示错误,同时选择的文件也会刷新。如何在不刷新选择文件的情况下给出错误信息?





感谢高级。

Dear Friends,

I have First one image upload (File Upload) & second one TextBox, now my issue is whenever click submit button if there is no data in textbox it will show error, at the same time the choosen file also refreshed. How to give error message without refreshing the choosen file?


Thanks in Advanced.

推荐答案

引用:

将文本框和标签放在updatepanel中,并为下面的按钮点击事件写入触发器,然后fileupload控件值不会改变





place textbox and label inside updatepanel and write trigger for button click event like below then fileupload control value wont be changed


<div>
       <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>

               <asp:FileUpload ID="FileUpload1" runat="server" />

       <asp:UpdatePanel ID="updatepnl" runat="server">
           <ContentTemplate>
       <asp:Label ID="lblmsg" runat="server" Text=""></asp:Label>
       <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                </ContentTemplate>
           <Triggers >
                 <asp:AsyncPostBackTrigger ControlID="Button1" EventName="click" />
           </Triggers>
       </asp:UpdatePanel>
       <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
   </div>


这篇关于如何编写fileupload&amp;的代码文本框。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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