Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Assign a CSS to a DIV

Posted on 2010-08-30
4
Medium Priority
?
362 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 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses
Course of the Month11 days, 23 hours left to enroll

916 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