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

  • Home
  • SEARCH
  • 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 8545383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:46:45+00:00 2026-06-11T12:46:45+00:00

Been banging my head against the wall and Google try to find the answer

  • 0

Been banging my head against the wall and Google try to find the answer to my problem.

When the below IF statement executes is appears to be running completely through the IF and ELSE statements.

  if (IsPostBack)
         {
             Boolean bFileOK = false;

             if (fulReagentImg.HasFile)
             {
                 String sFileExtension = System.IO.Path.GetExtension(fulReagentImg.FileName).ToLower();
                 String sFileExtensionLabel = sFileExtension;
                 lblFileExtension.Text = sFileExtensionLabel;
                 String[] allowedExtensions = { ".gif", ".png", ".jpeg", ".jpg" };
                 for (int i = 0; i < allowedExtensions.Length; i++)
                 {
                     if (sFileExtension == allowedExtensions[i])
                     {
                         bFileOK = true;
                     }
                     else
                     {
                         lblException.Text = "Can only upload .gif, .png, .jpeg, .jpg";
                         lblException.CssClass = "red";
                     }

 }

Any ideas why it’s not stopping with bFileOK = true?

  • 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-11T12:46:46+00:00Added an answer on June 11, 2026 at 12:46 pm

    Because your sFileExtension is a single extension, not all four of the allowed extensions. This means that even if the sFileExtension is ONE of the allowed extensions, it will still not be the other three, so no matter what, your else statement will get hit.

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

Sidebar

Related Questions

I've been banging my head against the wall on this trivial problem for hours.
I've been banging my head against a wall with this one for a couple
I've been banging my head against the wall all night trying to figure out
I've been banging my head against the wall for awhile on this but here
I have been banging my head against the wall with this odd behaviour on
I've been banging my head against a wall on this one. I'm working on
I've been banging my head against the wall for a couple of days on
I am having a problem and have been banging my head aginst a wall...
i've been banging my head against the wall, i need a sed one-liner to
I've been banging my head against a wall with this code all morning and

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.