I already wasted a lot of time on a basic problem, I have a .cshtml razor view that have a model of type DataTable and this datatable have some TableRows with one column that stores an image byte array. how can I assign this model value to an image element in the view. this is what I've came up so far.
var binaryData = @Convert.ToBase64String(Model.Rows[0][0] as Byte[]);
var img = document.getElementById('ImgEle')
.setAttribute('src', "data:image/jpg;base64," + binaryData);
I'm receiving this error at chrome console window : Uncaught SyntaxError: Invalid regular expression flags
how can I fix this problem?
Edit:
Thanks to @hiltononline answer this is the code I'm ended up with and its working fine
var binaryData='@Convert.ToBase64String(Model.Rows[0][0] as Byte[])';
var img = document.getElementById("ImgEle");
img.setAttribute("src", "data:image/jpg;base64," + binaryData);
Hope this will help somebody.