Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 977999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:59:39+00:00 2026-05-16T03:59:39+00:00

I am in the middle of creating an HtmlHelper method to generate code for

  • 0

I am in the middle of creating an HtmlHelper method to generate code for various html elements with a width and height. I have a class like the following simplified example.

public class Media {
  public string Url { get; set; }
  public System.Drawing.Size Size { get; set; }
}

I will be generating some HTML like the following.

<video width="360" height="280">
  <source src="{Media.Url}" type="video/mp4"></source>
</video>

OR

<div style="width:100%;height:50%;background: url({Media.Url});">
  ...
</div>

However, I would like to be able to store width and height as either pixels OR as percentages in my Media class. I considered just storing the values as strings, but in my application, I need to be able to multiply and divide the values because I am going to scale the elements at various parts of my site.

Is there something built into the .Net Framework that makes managing sizes as pixels or percentages easy?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T03:59:39+00:00Added an answer on May 16, 2026 at 3:59 am

    System.Web.UI.WebControls.Unit lets you store pixels or percentage.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am in the middle of creating a CCleaner like application for unix based/styled
I am creating a table which I want to have a top part, middle
I'm in the middle of creating a html to pdf converter using the wkhtmltopdf
I am in the middle of creating some generic class. And I create three
I am creating an iPhone application and I have a UIScrollView. I'd like to
I am in the middle of creating a simple/quick translator that just translated selected
I'm in the middle of creating a fairly large flex application, and over time,
I'm in the middle of building an application but found myself too easily creating
I am in the middle of a software development class and am trying to
I'm in the middle of creating a Drupal site. It already has lots of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.