Solved

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

Posted on 2010-09-20
3
1,741 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 74

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 74

Expert Comment

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

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Round a string to two digits 12 24
VB.Net - CSV to Oracle table 4 29
Create XML 5 33
Redacting a row in Excel based on a term. 17 33
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

706 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now