如何在asp.net项目中更改图像 [英] how to change image in asp.net project

查看:85
本文介绍了如何在asp.net项目中更改图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我用C#code开发了自己的asp.net项目.在其中放置了一个用于显示我的照片的图像控件.现在我需要用妈妈的照片代替.
现在我在myhome.aspx中进行更改

hi all,

i am developed own asp.net project in C#code. in that placed one image control to the purpose of displaying my photo. now i need to replace with my mother photo.
now i am changing in myhome.aspx

<asp:Image src="Images/myphote.gif" />

//更改前先带我的照片
------现在我要像下面这样改变--------------

//with my photo before changes
------Now i am changing like below-------------

<asp:Image src="Images/mymotherphoto.gif"/>

现在,我在像这样更改后会这样更改但未显示图像
并尝试使用

now i changes like this after changing like this but not image displayed
and also tried with

<asp:Image src="~/Image/mymotherphoto.gif"/>


注意:在我的项目中有Images文件夹.在该文件夹中,我还添加了我的照片.

请有人帮我......


在此先感谢


naresh


Note: in my project had Images folder.in that I also added my photo also.

please anybody help to me ......


thanks in advance


naresh

推荐答案

不要将图像添加为资源.我宁愿执行以下操作:

创建图像/图标并将其保存到文件中
选择项目->添加现有项并添加文件
将构建操作"设置为嵌入式资源"

然后,您可以使用
访问此资源
Don''t add the image as a resource. I would rather do the following:

Create the image/icon and save it to a file
Choose Project -> Add Existing Item and add the file
Set the Build Action to Embedded Resource

You can then access this resource using
Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceUri)



这样,就不会将图像神奇地添加到项目资源文件中,并且您将只在程序集的资源中存储图像的一个副本.



This way the image is not magically added to the projects resource file and you will only have one copy of the image stored in the assembly''s resources.


这篇关于如何在asp.net项目中更改图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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