如何在服务器asp.net C#上传后在Image控件中显示图像 [英] How to display image in Image control after upload on the server asp.net C#

查看:54
本文介绍了如何在服务器asp.net C#上传后在Image控件中显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在服务器asp.net C上传后在Image控件中显示图像#



无需按任何键或上传按钮

How to display image in Image control after upload on the server asp.net C#

Without pressing any key OR UPLOAD BUTTON

推荐答案

你需要将图像控件的图像URL设置为与图像的Url一样精确以及正确的扩展名(.gif,.jpg,.bmp),并且在执行相同操作后您不需要之后更改代码中的任何内容。



无论您将上传到具有相同名称和扩展名的网址的图像,它都会自动显示在图像控件中。









如果你想拥有动态图像而不是固定名称然后你需要在表格的页面加载时执行以下操作



u need to set image url of the image control to exact as the Url of the image along with correct extension(.gif,.jpg,.bmp) and after doing the same you do not need to change anything in the code afterwards.

Whatever image you will upload to the url with same name and extension it will automatically appear in the image control.


Or

If you want to have dynamic image and not with the fixed name then you need to do the following at page load of the form

protected void Page_Load(object sender, EventArgs e)
{
    string[] img = Directory.GetFiles("YourImage Path here");

    Image1.ImageUrl = img[0];
}







你将实现目标..



希望它可以帮到你。




and u shall achieve your goal..

Hope it helps you.


这篇关于如何在服务器asp.net C#上传后在Image控件中显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆