Solved

Assign a CSS to a DIV

Posted on 2010-08-30
4
353 Views
Last Modified: 2012-05-10
OK, let me first start by saying I'm NEW to ASP.net, so I hope this question doesn't sound stupid!

I have a DIV inside a Content Place Holder so I can change the width and background color to something different from the Master Page.
Here is an example of what it looks like now:
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder" Runat="Server">
    <div style="width: 1000px; background-color:White">

I would like to move these settings to a CSS file instead of having them set in the form, so I can swap out files at will.  I would like the CSS file to contain my width: 1000px and background-color:White so I can change these files in out based on a report selected.

You see I have a Crystal Report Viewer inside a Content Place Holder and I would like to change the width of the DIV when the report is Landscape vs. Portrait, so that the report shows behide a White Background vs. a green background on the Master Page.

Thanks,
Mark
0
Comment
Question by:smithmrk
  • 3
4 Comments
 
LVL 35

Accepted Solution

by:
YZlat earned 500 total points
ID: 33561924
<div class="fakefile">

one way would be to create a class in your css file and then set <div class="mycalss">

another way would be giving your div an id :

<div id="mydiv">

and then in your css file using div id to set the properties
0
 
LVL 35

Expert Comment

by:YZlat
ID: 33561976
  <div style="width: 1000px; background-color:White">

div.myclass
{
  WIDTH: 1000px;
  BACKGROUND-COLOR: White;
}
0
 
LVL 35

Expert Comment

by:YZlat
ID: 33562008
you could also use jquery:

$("#myDiv").addClass('myClass');
0
 

Author Closing Comment

by:smithmrk
ID: 33562221
Thank You!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
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 …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
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…

791 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