开发者

Setting an asp.net HiddenField from JavaScript callback

开发者 https://www.devze.com 2022-12-12 16:19 出处:网络
So I\'m using the awesome jquery plugin -- jQuery Ajax Upload 开发者_高级运维and after a file is uploaded, this code is run:

So I'm using the awesome jquery plugin -- jQuery Ajax Upload

开发者_高级运维and after a file is uploaded, this code is run:

// Called when upload completed successfully (puts success details into hidden fields)
upload_success_handler: function(file, response) {
    $("input[name$=_filename]", container).val(file.name);
    $("input[name$=_guid]", container).val(response);
    $("#<%=hdnFileName.ClientID %>", container).val(response);
    //I TRIED SETTING THE ACTUAL CLIENT ID, BUT STILL NO
    $("ctl00$MainContent$hdnFileName", container).val(response);
    $("ctl00_MainContent_hdnFileName", container).val(response);        
    $("span[id$=_completedMessage]", container).html("Uploaded <b>{0}</b> ({1} KB)"
                .replace("{0}", file.name)
                .replace("{1}", Math.round(file.size / 1024))
            );
    width = 0;
},

The response is coming from an HTTP handler which saves the file and then shoots it off to flickr and the response is a Photo Id. This all works great, but I can't get my asp.net HiddenField to get the value of the response.

Does anyone have any idea how to figure this out?

The non-asp.net hidden field values seem to get the response, so I'm assuming I'm just setting the name of the control wrong.

Thansk guys!


$("ctl00_MainContent_hdnFileName", container).val(response)

should be (note #)

$("#ctl00_MainContent_hdnFileName", container).val(response)

This expression should set value to hidden input on client side, but I didn't get what "I can't get my asp.net HiddenField to get the value" actually means?

0

精彩评论

暂无评论...
验证码 换一张
取 消