Solved

show image from db in stylesheet

Posted on 2011-09-09
4
245 Views
Last Modified: 2012-05-12
Hi.
I have a db with some image and i can see the images with this line of code.
<asp:Image ID="Image1" runat="server" ImageUrl="showImage.ashx?autoId=3"/>

that works, but now i have this code on my main site in a <style></style>
}
.ie7 #featured-v1,
.ie8 #featured-v1 {
      background: url(add/img/married.png) 0 0 no-repeat;
}
.ie7 #featured-v2,
.ie8 #featured-v2 {
      background: url(add/img/children.png) 0 0 no-repeat;
}
.ie7 #featured-v3,
.ie8 #featured-v3 {
      background: url(add/img/group.png) 0 0 no-repeat;
}
.ie7 #featured-v4,
.ie8 #featured-v4 {
      background: url(add/img/student.png) 0 0 no-repeat;
}

How can i changes the stylesheet code to use
showImage.ashx?autoId=3   and not     add/img/student.png
so it will use the image from the db in the stylesheet code and not the image from the folder.
0
Comment
Question by:tjgrindsted
  • 2
  • 2
4 Comments
 
LVL 18

Accepted Solution

by:
ivan_vagunin earned 200 total points
ID: 36513198
Hi!
I guess just like this:
background: url(/showImage.ashx?autoId=3) 0 0 no-repeat;
0
 

Author Comment

by:tjgrindsted
ID: 36515976
is that all..he he THX

Maybe u can help me wit this little thing then..
I have this little code
<asp:TextBox ID="txt_imgMainTitle" TextMode="multiline" runat="server"></asp:TextBox>
When i use ENTER it make a line jump, when i then save the text to my DB with this code:
cmd.Parameters.Add("@img_maintitle", OleDbType.VarChar).Value = txt_imgMainTitle.Text
and i see the text in live view the text is without <br /> for the Enter Jump, how do i add this <br /> to the text saved in the DB if i use Enter Jump in the TextBox TextMode="multiline" !?
0
 
LVL 18

Expert Comment

by:ivan_vagunin
ID: 36516408
Hi!
New lines are not encoded like \r\n in text box (not <br/>), so try following:
cmd.Parameters.Add("@img_maintitle", OleDbType.VarChar).Value = txt_imgMainTitle.Text != null ?txt_imgMainTitle.Text.Replace("\r\n", "<br/>") : ""';
0
 

Author Comment

by:tjgrindsted
ID: 36518684
I fix it with
<%# Replace(Container.DataItem("img_maintitle"), vbCrLf, "<br />")%>
bc. i can see that if i want to edit the text again then i can get some problems with the <br /> tag there.
But thx alot.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

775 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question