簡體   English   中英

如何將值從處理程序傳遞到ASPX頁面作為響應

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM