[英]How to pass a value from handler to aspx page as a response
I am adding the file name as the response in the handler, and in my JavaScript I am trying to get the value that I added in the handler and save that to a hidden field. 我正在将文件名添加为处理程序中的响应,并且在我的JavaScript中,我试图获取在处理程序中添加的值并将其保存到隐藏字段中。 The hidden field value however is always null.
但是,隐藏字段的值始终为null。 I am not getting the file name that I add to the response.
我没有得到添加到响应中的文件名。 How do I get the filename as response from handler
如何获取文件名作为处理程序的响应
public class Upload : IHttpHandler, System.Web.SessionState.IRequiresSessionState
{
public void ProcessRequest (HttpContext context)
{
context.Response.Write(filename);
context.Response.StatusCode = 200;
}
}
<script type="text/javascript">
$(document).ready(function () {
$("#<%=AFU_Video.ClientID%>").uploadify({
'uploader': 'scripts/uploadify.swf',
'script': 'Upload.ashx',
'buttonText': 'Video',
'cancelImg': 'images/cancel.png',
'folder': 'D:\Media',
'fileExt': '*.mp4',
'fileDesc': 'Video Files (.mp4 Only)',
'multi': true,
'auto': true,
'onComplete': function (event, ID, fileObj, response, data) {
document.getElementById("<%= Hidd_VideoLoc.ClientID %>").value = response.filename;
You are trying to use the filename
property of the response object, but as you are returning plain text there is no such property. 您试图使用响应对象的
filename
属性,但是当您返回纯文本时,没有这样的属性。
Just use the response: 只需使用响应:
document.getElementById("<%= Hidd_VideoLoc.ClientID %>").value = response;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.