如何将值从处理程序传递给aspx页面作为响应

时间:2012-02-06 11:52:18

标签: c# javascript asp.net uploadify

我在处理程序中添加文件名作为响应,在我的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;

1 个答案:

答案 0 :(得分:3)

您正在尝试使用响应对象的filename属性,但在返回纯文本时,没有此类属性。

只需使用回复:

document.getElementById("<%= Hidd_VideoLoc.ClientID %>").value = response;
相关问题