How do I set the contents of an ASPxImageZoom cont

2019-08-07 18:49发布

问题:

I am trying to write a property editor for the Dev Express ASPxImageZoom control so that I can use it in an XAF application to display an image.

The image is stored in a byte array.

I want to set the value of the control to contain the contents of a byte array.

However I cant figure out how to do this from the documentation. https://documentation.devexpress.com/#AspNet/clsDevExpressWebASPxImageZoomtopic

回答1:

You can assign byte array to ASPxZImageZoom control. In below code, I am just reading a file and converting it to byte array but you can directly assign your byte array.

protected void Page_Load(object sender, EventArgs e)
{
    string filePath = Server.MapPath("~/Images/41LR9-Q2W-L._AC_UX500_SY400_.jpg");
    if (File.Exists(filePath))
    {
        Byte[] bytes = File.ReadAllBytes(filePath);
        string base64String = Convert.ToBase64String(bytes, 0, bytes.Length);
        ASPxImageZoom1.ImageUrl = "data:image/png;base64," + base64String;    
    }            
}

Hope help you implement in correct way. It just for reference. care to error handling for such implementation.