Solved

How can i convert a System.Web.Ui.WebControls.Unit object from Percent to Pixels

Posted on 2008-10-22
8
576 Views
Last Modified: 2013-12-25
I am drawing graphics dynamically for my web page and need to convert the System.Web.Ui.WebControls.Unit object from percent to pixels if it is supplied in that unit type.  Is there any way to do this?

Thanks.
0
Comment
Question by:eddyevations
[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
  • 4
  • 3
8 Comments
 
LVL 17

Expert Comment

by:Daniel Reynolds
ID: 22782095
The following link may prove helpful to you.

http://support.microsoft.com/kb/79604
0
 

Author Comment

by:eddyevations
ID: 22785274
Thanks,
But i think this will not work on the web...this seems like more of a windows forms solution.
0
 
LVL 10

Expert Comment

by:Bane83
ID: 22786007
Do you know the full size of the image?  Couldn't you just do fullsize * percent = pixels?
0
Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

 

Author Comment

by:eddyevations
ID: 22790505
I am creating the image based on the control that is hosting it.  If the control is sized in percent i do not know how to convert that to pixels.
0
 
LVL 10

Expert Comment

by:Bane83
ID: 22790603
Ah, I think I understand.  So you're drawing new images (not pulling them from the database or anything) and they need to go into an asp:Image (or perhaps as a background-image to a div or something?) control that's on the page, however you're concerned that the asp:Image control may have it's Height and/or Width set to something like 80% x 90% and you're not sure how to convert that.  Am I right so far?

Well, the way to handle this changes depending on the control that you're trying to place the image in, so please give me a bit more detail.  Let me know how close I am and fill in whatever else you can.
0
 

Author Comment

by:eddyevations
ID: 22791432
Yes, you are correct.  I am trying to dynamically draw an image as the background of a panel.  There are three panels side by side and i know the width of the one on the left and the one on the right, but the centre panel needs to by dynamic based on the width of the control minus the left panel and the right panel... So, if the control width is given in something other than pixels, i need to be able to convert that to pixels in order to create my graphic for the centre panel.

Thanks.
0
 
LVL 10

Accepted Solution

by:
Bane83 earned 500 total points
ID: 22793354
Hum, definitely a tricky one.  I don't suppose there's any way for you to always know the exact width of the parent to the control?  Of course not, that would make life easy. :P

Well, there's no way for you to know the width of the control until it's actually been rendered (except for in the above case some times).  This means you'll have to use some AJAX callbacks.

Once your page is done loading, you can find the control in the DOM and get the offsetWidth property.  This will tell you it's pixel width on screen.  You can then subtract the pixel widths of the left and right panels from it and make your AJAX call to the image generator.
0
 

Author Closing Comment

by:eddyevations
ID: 31508978
Thanks Bane83.
0

Featured Post

Report: Liquid Web beats Amazon, Rackspace & More

A study by performance analyst firm Cloud Spectator finds that Liquid Web beats rivals Amazon, Rackspace and DigitalOcean when it comes to website and cloud application performance.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Node.js 11 82
How to set up WAMP on a windows 8.1 IIS machine 14 46
Wordpress contact form sending spam 2 52
Ajax calendar distorted 4 21
Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

739 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