asp:image; image url from .css problem...

Hello.  I have an asp:image, and i want it to get its image url from a stylesheet.  As this image is used in many places in the app, it makes it much easier to change the image or reorganize my images folder if the image path is in one location.

Currently, this is how it is:
<asp:image image-url='~/img/rtp.gif' runat='server'>
I have tried this:
<asp:image runat='server' cssClass=commonRTP>
And my stylesheet is:
..commonRTP {
background-image: url(/equicareweb/img/b-return.gif) ;
background-position:left middle;
No matter what I try, the 'empty image' box shows up with my real image hiding a little in the backgroud.
Does anyone know if it is possible to do what I am trying to do? I am starting to think it cant be done....
Thanks in advance,
6/18/2004 7:39:39 PM 24353 articles. 2 followers. Follow

6 Replies

Similar Articles

[PageSpeed] 51

What really are you trying to do?!

asp:image is just a server side acessible version of HTML <img> tag. To set the image requires src or ImageURL for asp:image. You don't use CSS to set a background for a image. You use CSS to set a background for a table, div, body etc not an image!?
6/18/2004 8:34:09 PM
I was trying to set the image-url property of the <asp:image> in my stylesheet.  Unfortunatley, the .css didnt recognize that as a valid I tire the background url..

I guess I should have been more clear, but what I want is this:
I want the image-url property for my asp:images to be taken from a stylesheet.
6/18/2004 8:38:31 PM
are you sure this is possible?  I have never heard of such.

alternatively you could set the ImageURL = to a variable and change it only in code.
6/18/2004 8:47:43 PM
No, I'm not sure if it is possible, which is why I am asking the question.

If can set the image-url in a .css using the "~/img/image.gif" format, then I can change images or re-organize my img folder and only have to change the code in one location...that makes it worth trying...
6/18/2004 8:57:21 PM
The tilde(~) is a server-side shortcut for the currently executing application path.  This will only be translated by controls that are processed on the server-side.

It seems to me that you'd be better served by turning your "image that's used everywhere" into its own control. Then, when you restructure, you only hvae to change that control and not everywhere that it's included...
6/24/2004 7:21:16 PM
You are of course correct.  I was afraid that that would be the only option.  Unfortunately, we are deep enough in the development process that it would be a bit impractical at this stage.  The idea of using the .css would have been easier.

Thanks for the clarification!
6/24/2004 8:14:34 PM

Similar Artilces:

CSS background-image:url(image url); problem
I have a ASP.NET2.0 application in VS2005. My problem is i am not getting images from image folder by using css background-image: url(Images/greenBack.jpg); My folder strcture is like this: |-- Folder:App_Themes | | | |--->Folder:MyTheme | | | |--->Folder:CSS | | | |--->Folder:RealCSS | | | |-->File: mystyle.css | |-- Folder:Images | |-->greenBack.jpg What will be the css code? Hello,      You can use rela...

How to Insert Image Url and Display the Image of that Image Url in the Grid View?
Any one can help me out about this- How to Insert Image Url and Display the Image of that Image Url in the Grid View Hi You can add HyperLink control to Gridview by setting its ImageUrl and NavigationUrl property Please refer example. <asp:HyperLink ID="HyperLink1" ImageUrl="images/image.gif" NavigateUrl="PageUrl.aspx" runat="server">HyperLink</asp:HyperLink>Please mark the post as answered if it helped you. Hi sandynaidu, This is easy to solve. Assuming that your GridView's ID is gv, that you want to have the image in your firs...

Image Url
 I have a Image control which will display the selected image from the client File system(ie : the image is not been uploaded untill the user press save button)When the user browers a image which contains space in the image path(eg:C:\Documents and Settings\user\Desktop1.jpg), then that image is not been displayed <script runat="server"> protected void btnShowP_Click(object sender, EventArgs e) { Image1.ImageUrl = FileUpload1.PostedFile.FileName; } protected void btnSave_Click(object sender, EventArgs e) { Sys...

How to link image on the client side not using image control
Hello: I need to link my image on the client side code, but not use image control. Is anyway like ASP to use: img src="../image/photo.gif" ?  Thanks    You meant  without adding image control you wanted to add an image and give the link for that? please give more details... Don't forget to click (Mark as Answer) on the post that helped to solve your problem. Yes. In ASP, you specify the image path: img src="../image/photo.gif". I put image in the folder image. How to specify this path and find image without using image contro... problem: i can not view image data for the rest of my table rows except the image for the first row but i can read all the other non image fields for all rows.
Hi i have a table with the following fields imgdata........image imgtitle.........varchar(max) imgType........varchar(max) imgLength.....bigint i have no problem with uploading the image but viewing the uploaded image(s) in a gridview has caused me great pain. The probelm is i have two pages. page1 grabs the image to display and page2 has a gridview that displays the grabed image. I wanted to have an sql statement like SELECT * FROM mytable WHERE incident_id=someValue. IF i have 5 records in this table and i view page2 ...

Imaging, but not imaging
We multicasted to 43 machines. Updated the image on the master. Multicasted the updated image to 36 machines. (the other 7 wouldn't join the session for some unknown reason). I visually verified that all 36 were imaging. One of the 8 which didn't rename appears to not even have been imaged. The problems with the previous image were still there. It's as though the machine didn't image even though I saw it take part in the session and the temp bar going across the screen. What the heck's going on here? AlaN As a try, what happens if you boot either to PXE ...

Image in image
Hi, I have a project where clients viewing my website can buy t-shirts. They can choose from a number of t-shirt colors and shapes which are their plain colour. They can also choose a number of prints to be placed on the t-shirt. These will be graphics stored in a database. My problem is on how I can displaty the t-shirt with the graphics or logo they chose on te t-shirt. It would be something like drawing text on an image but instead drawing an existing image on the base image. Any Ideas? (I am using visual studio 2005 and vb.NET)   RegardsMerovingian you 1. You can create a...

Image on Image
I am trying to display a page that has image of a map on it. The user can then place other images of red thumbtacks on the image at different locations. Then when these thumb tacks are clicked on, they open a folder of pics related to the area. I saw a method in the imageButton class that returns the (x,y) of the location where the user clicked. I thought I could use this information to place another, smaller image button, on that area. My problem is that i can't seem to get the bottom imageButton to be transparent so I can see the smaller one. Am i on the right track with this. Any advi...

image and image
// create an image object, using the filename we just retrieved System.Drawing.Image image = System.Drawing.Image.FromFile(Server.MapPath(file)); // create the actual thumbnail imageSystem.Drawing.Image thumbnailImage = image.GetThumbnailImage(64, 64, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero);   now my question is how to display this image in my image1 control in (version 1.1) the below line of code is not working.  Image1.ImageUrl=thumbnailImage.ToString();Mark As Answer If my reply helped you. Hi, you can save t...

two image control how to pass different image url from css file
there r two image control how to pass the different image url of that image from css file how to pass  different image url from that image url in ur css file are the path how to take that url to ur image url sanjib420:there r two image control how to pass the different image url of that image from css file how to pass  different image url from that image url in ur css file are the path how to take that url to ur image url Hi friend, I am not sure what is your mean? Could you give me an example? Waitting for your feedback, Hong GangHong-Gang ChenMicrosoft Online Community Su...

Loaing Image to an Image COntrol using client side java script
SIr How can I Load an Image to an Image Control using JavaScript Expecting reply C T Ranjith Hi ctranjith, Try the following snipplet and then call it wherever you need it: function LoagImage() { document.getElementById('imgControl1').src = document.getElementById('btnExplore').value; } Hope it helps.MIGUELÓN.-----------------------------------------Rezad a vuestros dioses, amad a vuestras mujeres y luchad por vuestra patria! ----------------------------------------...

problem loading an image from client side code
Hello, Having an issue with my ASP.Net page. I use some COTS, which for all intents and purposes, simply makes a jpeg file and physically places it in a directory on the web server. The page load codebehind, makes a connection to the jpeg creation service and gets the path of the newly created image. The sample code I'm providing is very simple... no rocket science here.  Here's the code behind:     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load       Dim j As New jpegImage   &nb...

Url Rewriting Images & CSS problems
hello r u ?Url rewriting is working but my problems isproblem : i have have used Datalist and paging at that time when i go to other page my path for CSS and IMAGES  are not working properly...pls give me solution.  Jay "Enjoy Life"...

Assign an image to an image element based on querystring within Client-Side code
HelloI want to change the main image of a page by just clicking thumbnails of other imagesI placed images each in a seperate div and I defined events forclicking each div .In my opinion From 2 aspects this code can have problems1 . the querystring part2 . the assigning of the clicked image  to the main ImageI have some folders that inside of each folder I named my images a,b,c,d for ease of usewith QueryString . I used these codes for getting the querystring and assigning an image to the main imageCode : A seperated JavaScript file named Q.js  <code>function Qu...

Append two images to one image side by side
Hi, Can we append two images to one image.Suppose I have "A" and "B" two charecters in two images.can I combine this two mages into one and show AB side by side in one image. Hi, Check this,Sandeep Kumar MCPD - Web DeveloperMCTS - .NET Framework 2.0: Web Applications--------------------------------------------------Software Associates ASP.NET Dev:Hi, Check this

Image Button Image Url
Hi , I' m using a Image Button in the Grid View and propulating its image url in the code behind page when some conditions are satisfied, otherwise the iamge is invisible. the image is loaded on my localhost but not on the Test site. It is getting the right URL and the image is present in the folder it is looking for and has all the permisssions to view it. I' m clue less why a small rectangle with a red cross is seen and not the image.Any help would be greatly appreciated. Here is my sample code. Image button in the aspx page. <asp:TemplateField HeaderText="Print&quo...

Problems with a thumbnail image to popup Full-size image (image paths from a database)
I am hoping to get more feedback from entering this in perhaps a more appropriate forum.   Please refer to post   I think I’ve explained what I would like to do but can’t figure out how to successfully code it.   I found it interesting that if I removed the Onclick event, my Bind error goes away.   And changing the Bind to an Eval traded the Bind error for a parser error.   How can I pass the path of the Full size image from my DB to the javascript so that ASP and Java both are OK with the coding?  ...

Problems running client side code from an embedded image button
I have a datalist control with an embedded image button associated with each item. During databind I generate a small javascript to show the image in a popup window when the button is clicked (code shown below) ImgButton.Attributes["onclick"] = javascript:popup('../images/popup.jpg','Large Image'); I think the proper HTML is being generated (shown below) but the popup window doesn't seem to come up. <input type="image" name="dlGlossary:_ctl1:imgbtnGlossaryImage" id="dlGlossary__ctl1_imgbtnGlossaryImage" onclick="javascr...

display image in a image image button
hi   i have to display an image in image button while uploading mycode Image1.ImageUrl = Upload.PostedFile.FileName; is not working thanks Hi You need to save the PostedFile to the disk on the server and then assign it to ImageUrl. Take a look at the following links for more infoprmation on how to do this. Nassabehwww.professionalcsharp.comDon't forget to click "Mark as Answer" on the post that helped you. That way ...

!!!!! Image on master page wont show when image url is set to a image from content page !!!!!!
 Hi guys, I have this problem which i cannot seem to understand... here goes... i have a master page and an image control on is a social networking website and then i have a content page..there is a link button on the master page when when clicked shows a modal popup which has a fileupload control and a user can submit an image file...when he does so the image get saved in a directory and also its complete address is saved in the 2 problems... after committing these actions (on the master page code file ) i set the image url to the saved path ...

JPEG image over Tranparent Image problem
Hi, I am just started my career as a developer few months back  and I am in my first project and I am struck. Please help. I am developing  a website with and C# In one of the web page, in an Image control, I have to display an image over an other image which I sucessfully did with various code articles help from the web. Now, in one scenario I have to place a smaller image first. Then over that I have to place a gif image(in which there is a circle transparent area). It is something like placing a photo in a photoframe. With some help from the web, I am able to d...

Problem retreiveing image from /images folder
Hi all, I have a simple search that would search for an image and print it out. Currently, my code is fine when the images are stored in the root folder.But when I code the DB to store the images into ~/Images i can retrieve the result but not the image in my Dataset.How do I make it so I can retrieve the images from the /Images folder regards  It would help if you posted the code that is either saving or retrieving the images. It may be as simple as using Page.ResolveUrl("~/Images/...") to get the correct virtual path, or Server.MapPath() to get the physical path.Mark...

How to Insert the Image URL into Sql database and display that particular Image of the URL in GridView
 How to Insert the Image URL into Sql database instead of storing the original image itself and display that particular Image of the URL dynamincaly in GridView.For example for each product there will be one image ,here i want to store that Image URL (locally/in other Links) into the Sqldatabase and on selecting foran particalur product id i want it to display that image of the product in Grid View.How can i proceed........?i am seeking for help.   If I understood you question this is not very hard 1.  Created a table id, description and ImgUrl.  The ImgUrl field ...

Reload Image in Image Control Problem!
hi,alli have a security image for user registeration,and i use Ajax to change picture when user can't read image,but there is a problem:when user click "Change Picture" image change only for one time!(Image Create in Physically path,but Previous image Show in image Control)i think,image control can't reload or physically path isn't refreshed! thanks for read my problem. Has the new image got the same name?  If so try using a new name and deleting the old file. I think the image is being cached. Add the below code to disable caching Response.Cache.SetCacheabi...

Retreiving Image URL from Datagrid Image
Hi There, Well this seems to be a little different to all the other image datagrid related questions. Whilst most people want to know how to get an image into a grid, I want to know how to get the image URL out of the grid :-) The section of the datagrid in question is : <asp:TemplateColumn HeaderText="Image"> <ItemTemplate> <asp:Image Width="52" Height="56" ImageUrl='<%# DataBinder.Eval(Container.DataItem, "Image") %>' Runat="server" /> </ItemTemplate> ...

Web resources about - asp:image; image url from .css problem... -

Resources last updated: 2/18/2016 8:22:20 PM