Solved

asp.net VB set background image of div tag in code behind

Posted on 2010-09-20
3
1,831 Views
Last Modified: 2012-05-10
Hi, I have a div tag and I want to set it's background image in my code behind file. How would I do this? Below is what I currently have, but it is not working. Thanks

Page:
<div class="image_bg" id="image_bg" runat="server">     <<<<<<<<<<<<<<< want to set this bg image
  <div id="menuwrapper">  
    <div id="menu">  
      <div class="menuitem">asdfasdfsf k jlkj kl; kl lkj l;k jlk jkl kl asdfasdfsf k jlkj kl; kl lkj l;k jlk jkl kl asdfasdfsf k jlkj kl; kl lkj l;k jlk jkl kl asdfasdfsf k jlkj kl; kl lkj l;k jlk jkl kl asdfasdfsf k jlkj kl; kl lkj l;k jlk jkl kl asdfasdfsf k jlkj kl; kl lkj l;k jlk jkl kl asdfasdfsf k jlkj kl; kl lkj l;k jlk jkl kl asdfasdfsf k jlkj kl; kl lkj l;k jlk jkl kl asdfasdfsf k jlkj kl; kl lkj l;k jlk jkl kl asdfasdfsf k jlkj kl; kl lkj l;k jlk jkl kl asdfasdfsf k jlkj kl; kl lkj l;k jlk jkl kl </div><!--Template for each menu item-->  
      </div>  
   </div>
</div>  

Code Behind:
Partial Class vertical_test
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        image_bg.background-image = "url(main_slides/slide1.jpg)")
    End Sub
End Class
0
Comment
Question by:elliottbenzle
  • 2
3 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 33719275
I believe you'll need to use the Style property of the div:
Me.image_bg.Style.Add("background-image", "url(main_slides/slide1.jpg)")

Open in new window

0
 
LVL 4

Author Closing Comment

by:elliottbenzle
ID: 33719539
YES! Thank you very mucho.
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 33719580
NP. Glad to help  :)
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
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 …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

733 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