?
Solved

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

Posted on 2010-09-20
3
Medium Priority
?
1,933 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 2000 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

Not sure which OpenStack Certification to get?

So you’ve realized you might want to get certified in OpenStack, but you’re not sure what the benefits might be or even which one you should take. You know there are several certification courses you can choose from, but how do you know which one is right for you?

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

752 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