问题描述
我使用Ajax文件上传控件上载文件,它工作正常,但当IA复选框或单选按钮已自动回
属性设置为true,我检查那么文件名
返回null值
I am using Ajax file upload control to upload file in which it works fine but when i a check box or radiobutton which has autopostback
property set to true and I check then the FileName
returns value null
protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
{
try
{
if (AsyncFileUpload1.IsUploading)
{
AsyncFileUpload1.SaveAs(MapPath("~/Images/Accounts/" + AsyncFileUpload1.FileName));
}
}
catch (Exception ex)
{
}
}
然后上传后的任何回发控件激发它只是返回null,视图状态也没有工作。
after uploading then any postback control fired it simply returns null and viewstate also not worked
推荐答案
使用视图状态,这将是通过使用回发所以首先值存储在一个JavaScript,然后按如下方式使用明确的服务器控件
use viewstate is a server control which will be clear by using postback so first store the value in a javascript and then use it as follows
的Java脚本方法:
function OnClientAsyncFileUploadComplete(sender, args) {
__doPostBack('filename', args.get_fileName());
}
function saveLogo(ImageName) {
__doPostBack('filename', args.get_fileName());
}
在页面加载普莱舍把下面的code:
in page load plese put the following code:
在.CS
if (IsPostBack)
{
string eventTarget = this.Request["__EVENTTARGET"];
if (eventTarget == "filename")
{
ViewState["EIName"] = this.Request["__EVENTARGUMENT"].ToString();
}
}
的ViewState [EIName]包含文件名
ViewState["EIName"] contains the file name
您可以使用任何地方在页面
you can use any where in the page
这篇关于而用ajax无法获取上传的文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!