如何在asp.net中设置图片网址 [英] How to set the image url in asp.net

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

问题描述

我遇到与asp.net相关的问题.每当我尝试将图像的url设置为背景时,调试后就不会在浏览器中显示.

 <   div    对齐  ="    样式  ="  >  


 <   body    背景  ="   http://msdn.microsoft.com/en-us/library/ex526337 .aspx  [^ ] 

具体行:应用程序文件夹的内容(App_Themes文件夹除外)不响应Web请求而提供,但可以从应用程序代码中访问."


hi,

嘿,创建一个文件夹图像并粘贴您在应用程序中使用的所有图像文件.
然后在aspx页面中使用以下标记在应用程序中使用该图像

 <   img     src   ="    高度  ="  32"  hspace    0"  vspace   ="    对齐  ="    样式  ="  >  <  >  


您提供的图像的绝对路径将不起作用.

首先应将图像添加到网站,然后将图像的路径分配给ImageUrl属性.


I am having problem related to asp.net. Whenever i tried to set url of an image as a background it doesn''t display in browser after debugging.

<div align="center" style="background-color: transparent; background-image: removed(App-Data/Images/blue.jpg);">


<body background="C:\Documents and Settings\sse\My Documents\Visual Studio 2008\Projects\WebApplication2\WebApplication2\App_Data\images\background.png">

解决方案

I think you should move your image to outside of App_Data because .net framework restricts web servers to directly access data from application folders(one of them is App_Data).
For more details read this article: http://msdn.microsoft.com/en-us/library/ex526337.aspx[^]

Specifically line:"The content of application folders, except for the App_Themes folder, is not served in response to Web requests, but it can be accessed from application code."


hi,

Hey create one folder image and paste all the image files which you are using in your application.
Then use that image in your application using following tag in your aspx page

<img src="images/bg0001.gif" height="32" hspace="0" vspace="0" align="left" style="width: 1050px"></img>


The absolute path of the image you are providing will not work.

The image should be first added to the website and then assign the path of the image to the ImageUrl property.


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

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