如何在Asp.Net上显示Div、Span、Label等位图图像?不要使用处理程序

发布于 2025-01-07 17:45:37 字数 110 浏览 4 评论 0原文

我想在 Div 中显示位图图像。我想从代码后面做。我不想使用处理程序。

像这样:

div.InnerHtml = BitmapImage;

I want to show been bitmap image in Div. I want to do from code behind. I want not to use handler.

Like This:

div.InnerHtml = BitmapImage;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

千年*琉璃梦 2025-01-14 17:45:37

非常简单的方法(请注意,您将发送大量数据):

将图像从位图转换为 JPG

获取图像的 base64(base64 图像的示例位于 http://jsfiddle.net/3sdGJ/)

通过写入添加图像:

div.InnerHtml = "<img alt=\"\" src=\"data:image/gif;base64,R0lGODl.......\"/>";

首选方法是保存图像作为服务器上的 JPG,然后

div.InnerHtml = "<img src=\"pathtoimage.jpg\"/>";

Pretty simple road to follow (note that you'll be sending a lot of data) :

Convert the image from bitmap to JPG

Get the base64 for the image (example of base64 image at http://jsfiddle.net/3sdGJ/)

Add the image by writing:

div.InnerHtml = "<img alt=\"\" src=\"data:image/gif;base64,R0lGODl.......\"/>";

The preferred way would be to save the image as JPG on the server and then

div.InnerHtml = "<img src=\"pathtoimage.jpg\"/>";
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文