How do I set the contents of an ASPxImageZoom control?

天涯浪子 提交于 2019-12-13 02:39:19

问题


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.



来源:https://stackoverflow.com/questions/34304258/how-do-i-set-the-contents-of-an-aspximagezoom-control

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!