Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 7th, 2007, 01:23 AM
Authorized User
Points: 375, Level: 6
Points: 375, Level: 6 Points: 375, Level: 6 Points: 375, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2006
Location: New Delhi,India.
Posts: 79
Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via AIM to anujrathi Send a message via MSN to anujrathi Send a message via Yahoo to anujrathi
Default retrieve attribute values from CSS(from class)

Hi experts,
I am facing a problem with stylesheets.
I hav some div in my page. I set their styles using stylesheet(with the help of id ).
Now i have to change their height & width using javscript.
But i am not able to get these values from CSS.

eg. document.getElementById('idname').height or
      document.getElementById('idname').style.height
is not working. first one shows null & later shows undefined.

But if i write these properties in style attribute then i can get it easily by
    document.getElementById('idname').style.height


Pls tell me that is there any way to pick attribute values from class name (means from css)

regards,
Anuj rathi
  #2 (permalink)  
Old May 7th, 2007, 01:57 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

As you are finding, style behavior that is dictated by a style sheet is not "readable" in the same way as styles that are applied using the style="..." inline attribute. However, there is usually a way of reading it.

When an element is drawn on the page it always has height and width and other similar properties (even if they are determined automatically by the browser based on the flow of the page versus being assigned specifically by an inline style or a CSS setting). This values are often available by prefixing "offset" to the style in question. Try using something like this:

document.getElementById('idname').style.offsetHeig ht

You can try the "offset" prefix for other values too:

.offsetWidth
.offsetLeft
.offsetTop
etc.

Hope that works for you.

-Peter
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to retrieve values from gridview rojiin ASP.NET 2.0 Basics 1 June 26th, 2007 07:32 AM
CSS Class rupen CSS Cascading Style Sheets 3 April 13th, 2007 05:35 PM
XSLT change class attribute by ID? matallen XSLT 8 March 1st, 2006 05:00 PM
Access to attribute values from class of attribute jacob C# 1 October 28th, 2005 01:11 PM
retrieve values of __VIEWSTATE marvz ASP.NET 1.0 and 1.1 Basics 2 July 13th, 2005 03:01 AM



All times are GMT -4. The time now is 06:44 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.