System.Web.HttpException: The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
As soon as I remove my Javascript code, it works fine. What is wrong with my script?
<script type="text/javascript">
function ShowImagePreview(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#<%=ImgPrv.ClientID%>').prop('src', e.target.result)
.width(240)
.height(150);
};
reader.readAsDataURL(input.files[0]);
}
}
function preventBackspace(e) {
var evt = e || window.event;
if (evt) {
var keyCode = evt.charCode || evt.keyCode;
if (keyCode === 8) {
if (evt.preventDefault) {
evt.preventDefault();
} else {
evt.returnValue = false;
}
}
}
}
function SetContextKey() {
$find('<%=acestate.ClientID%>').set_contextKey($get("<%=txtRef4.ClientID %>").value);
}
$(document).ready(function () {
window.history.forward(1);
});
</script>
EDIT:
I have googled it and found solution i.e., replace <%=
with <%#
, it's working but when I replace it then the image preview javascript code is not working. So, please provide me different solution.