[英]How to pass a value from handler to aspx page as a response
我正在将文件名添加为处理程序中的响应,并且在我的JavaScript中,我试图获取在处理程序中添加的值并将其保存到隐藏字段中。 但是,隐藏字段的值始终为null。 我没有得到添加到响应中的文件名。 如何获取文件名作为处理程序的响应
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;
您试图使用响应对象的filename
属性,但是当您返回纯文本时,没有这样的属性。
只需使用响应:
document.getElementById("<%= Hidd_VideoLoc.ClientID %>").value = response;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.