保持asp.net,C#中Fileupload控件中的值 [英] Maintain value in Fileupload control in asp.net,C#

查看:69
本文介绍了保持asp.net,C#中Fileupload控件中的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在更新面板中使用Fileupload和3下拉控件,将在下拉列表中将3下拉回发给选定的索引更改事件(例如,如Country,states和city ...从db中获取按国家,州和城市划分的值)

i am using Fileupload and 3 dropdown control in update panel, 3 dropdown will be post back on dropdown selected index change event (i.e like Country,states and city... get the value from db as per country,states and city)

问题是

回发时,文件名路径已从文件上传控件中删除(如预期/或默认属性).

While postback the filename path is gone from the file upload control(as expected/ or Default property).

我正在将文件转换为字节数组,以便通过文件上传控件存储在数据库中.

I am converting the file to byte array, to store in the database from file upload control.

我如何保留价值或有什么办法解决这个问题.

How can i retain the value or Is there any way to solve this issue.

是否有用于文件上传的ajax控件或任何在回发后仍保留值的免费控件??

Is there any ajax control for file upload or any free controls which retain the value after postback also...?

或者可以在回发期间将值设置为文件上载控制吗?

Or it is possible to set the value to file upload control during postback ?

提前致谢

推荐答案

您可以尝试使用asp.net ajax事件处理程序在异步回发之间的隐藏字段中持久保存文件上载值.

You can try to persist file upload value in hidden field between async post-backs using asp.net ajax event handlers.

Sys.WebForms.PageRequestManager.instance.add_beginRequest(BeginRequestHandler)
Sys.WebForms.PageRequestManager.instance.add_endRequest(EndRequestHandler)

function BeginRequestHandler(sender, args) {
  var fileUpload = document.getElementById('fileUpload');
  var hiddenUpload = document.getElementById('hiddenUpload');
  hiddenUpload.value = fileUpload.value;
}

function EndRequestHandler(sender, args) {
  var fileUpload = document.getElementById('fileUpload');
  var hiddenUpload = document.getElementById('hiddenUpload');
  fileUpload.value = hiddenUpload.value;
}

这篇关于保持asp.net,C#中Fileupload控件中的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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