I have multiple base64
strings which I need to send them from javascript
to ASP.NET
code behind. I use asp:HiddenField
now but the strings are so heavy that it takes a long time for these strings to be saved in hidden fields, and sometimes the browser crashes!
I also used this code to send data but it doesn't work and even if it works I cant perform further processes on strings because the method should be static.
Javascript:
$.ajax({
type: 'POST',
url: '/pages/panel/addproduct.aspx/UploadImage',
data: "{'imageData':" + "\"" + mainImage + "\"}",
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function (msg) {
alert("Done successfully.");
}
});
Code behind:
[WebMethod()]
public static void UploadImage(string imageData)
{
byte[] bytes = Convert.FromBase64String(imageData);
using (MemoryStream ms = new MemoryStream(bytes))
{
CroppedMainImage = System.Drawing.Image.FromStream(ms);
}
}
What is the alternative?