I write code in asp.net backend to pass parameter, however, I found that it does not work if the parameter is so long.
In the backend:
folderList.InnerHtml += "<span onclick='AttachId(" + folder.Id + ")'>" + folder.DisplayName + "</span>";
In the frontend:
function AttachId(id) {
$("[id$='hf_FolderId']").val(id);
$("[id$='btn_Move']").click();
}
The parameter folder.Id="AQMkAGQ2YzBkYjkxLWZjNTYtNDAwAS1hZWY2LWQ3OWI2MDkxZTE2ZAAuAAAD82EfyZcOUkeLGnLBkE1iOgEA04D3/FOc8ES6LdlZ5/AXHgAAAQRaEQAAAA=="
If I change it to “123” it works. Any idea?
Or maybe you could let me know a better way to pass parameter from back to front. Many thanks.
Quotes.
123is a number so JavaScript is fine with it. If you tryabc, I bet it fails as well. Add quotes to your string in the markup and it should work.Using string concatenation to generate HTML is always error prone. Remember, the JavaScript string needs to be quoted as does the HTML attribute it is contained in. Since you are using single quotes for your attribute, you must use either double quotes or htmlencoded single quotes for your JavaScript. This should work: