下拉列表更改时出现“文件上传"按钮的问题 [英] Problem With File Upload Button on change of dropdownlist

查看:60
本文介绍了下拉列表更改时出现“文件上传"按钮的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我在页面中有一个fileupload按钮和一个下拉列表.

在fileupload按钮中选择路径并且下拉列表的onselectedIndex更改后,fileupload按钮中的路径将被清除.

我知道它是因为dropwn列表的autopostback属性.但是我不希望在选择下拉列表时在文件上传中清除路径..

任何帮助或建议,将不胜感激.


谢谢,

Hi All,

I have a fileupload button and a dropdownlist in the page.

After I select a path in the fileupload button and onselectedIndex change of a dropdown, the path in fileupload button gets cleared off.

I know its because of autopostback property of a dropwn list. But I don''t want the path to be cleared in a fileupload on select of a dropdown list..

Any help or suggestion would be greatly appreciated.


Thanks,

推荐答案

亲爱的拉吉,

在设计中,将Fileuploader 放在页面的最后,在dropdownlist的每个回发中,都会清除fileuploader.因此最好将您的Fileuploader 放在页面的最后一页

谢谢
Ashish
Dear Raj,

In design, put your Fileuploader in last of the page, in every postback of dropdownlist, fileuploader will be cleared. so better to put your Fileuploader in last of the page

Thanks
Ashish


; asp:updatepanel id ="up1" runat ="server" xmlns:asp =#unknown">
< contenttemplate>

< asp:dropdownlist>
< asp:fileupload>

< asp:button id ="btnsubmitresut" runat =服务器" validationgroup ="aa" text ="submit" onclick ="BtnSubmit_Click"/>

< triggers>
< asp:postbacktrigger controlid ="btnsubmitresut"/>

;asp:updatepanel id="up1" runat="server" xmlns:asp="#unknown">
<contenttemplate>

<asp:dropdownlist>
<asp:fileupload>

<asp:button id="btnsubmitresut" runat="server" validationgroup="aa" text="submit" onclick="BtnSubmit_Click" />

<triggers>
<asp:postbacktrigger controlid="btnsubmitresut" />


AFAIR,由于安全原因,您将无法显示完整路径(最大可能是文件名)

将此代码通过selectedchanged事件方法添加到文件后面的代码中:
AFAIR, you won''t be able to show the full path because of security reasons (maximum possible would be filename)

Add this code in your code behind file in selectedchanged event method:
myFileUpload.Attributes.Add("value", fileNameYouWantToShow);




意见建议:
在所有回发之后,将fileupload控件保留在末尾,以便一旦提交页面,就可以从上载控件上载文件.您无需通过此实现即可在控件中维护文本.




Suggestion:
Keep the fileupload control at the end after all the postbacks, such that once page is submitted you can upload the file from upload control. You won''t need to maintain the text in the control via this implementation.


这篇关于下拉列表更改时出现“文件上传"按钮的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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