Solved

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

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
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…

770 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