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 8053439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:50:37+00:00 2026-06-05T07:50:37+00:00

I am trying to get the width in pixels of a an asp:Image. The

  • 0

I am trying to get the width in pixels of a an asp:Image. The image is not local.

imgUserThumb.Width.Value

Is always coming back as 0.0 anyone know why? Or perhaps thats not the right way?
Also the image is using an “onerror” attribute to check if the image URL passed to it is valid, if not then it displays a default thumbnail.

  • 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-06-05T07:50:39+00:00Added an answer on June 5, 2026 at 7:50 am

    If you not set width and height for the image tag, you will get 0.

    if you need to get actual size of image, load it to bitmap and get the width from there.

    Image img = new Bitmap("Mytest.png");
    var imgwidth = img.Width;
    

    EDIT from URL

    private  int GetImageWidth(string url)
    {
        int width = 0;
        using (WebClient client = new WebClient())
        {
            client.Credentials = new NetworkCredential("name", "pw");
            byte[] imageBytes = client.DownloadData(url);
            using (MemoryStream stream = new MemoryStream(imageBytes))
            {
                var img = Image.FromStream(stream);
                width=  img.Width;
            }
        }
        return width;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to get the height and width of an image in windows
I'm trying to get the width of a div container to set another css
Im trying to get a Gutter Width of 10px between my Div's, but it
I'm trying to get the width of an element with jQuery and then paste
I'm trying to get the value of an inherited CSS property using Javascript. I
I'm trying to get an image to display with one of the colors replaced
Im trying to get google maps to show 100% width and height. I have
i'm trying to get back a style property in all valid 'length' and 'percent'
I'm trying to get the following layout: Link to Image And this is what
I'm trying to resize a browser (I know... I know...) by the width only,

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.