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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:40:39+00:00 2026-06-01T01:40:39+00:00

In my codebehind, I set the display property of an asp.net control to none

  • 0

In my codebehind, I set the display property of an asp.net control to none as follows;

fuDoc.Attributes("style") = "display:none;" 'fuDoc is a FileUpload control. 

On my page, if the user wants to upload a document, they click on a link, which by using jQuery, I set the display property to 'block' by using .show() as follows;

$('#fuDoc').show();

I also tried;

$('#fuDoc').attr('style', 'display:block;');

now, on form submit, I need to check if the fuDoc is visible and if so, do the standard file upload process e.g. check .HasFile etc..

However, although the fuDoc control is set to display:block in HTML with no problem, the following asp.net code always produces True

If fuDoc.Attributes("style") = "display:none;" Then 'always results to true

What is the reason for this? Any help would be appreciated.

Note: the FileUpload control is NOT created dynamically.

  • 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-01T01:40:40+00:00Added an answer on June 1, 2026 at 1:40 am

    Rather than relying on detecting whether or not the FileUpload is visible on the page, you could include a TextBox or HiddenField such as:

    <asp:TextBox id="txtIsFileUploadShown" runat="server" cssclass="txtisfileuploadshown" Text="0" style="display:none;" />
    

    This control will be hidden on your page, storing the value of 0 by default.

    Whenever you hide/show the file upload, change your code to also change this value:

    $('#fuDoc').show();
    $(".txtisfileuploadshown").val('1');
    

    When hiding:

    $('#fuDoc').hide();
    $(".txtisfileuploadshown").val('0');
    

    Then in your code-behind on post back, simply check:

    If IsNumeric(txtisfileuploadshown.text) AndAlso Cint(txtisfileuploadshown.text)=1 Then
       'Do HasFile validation here.
    End
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to set the style of an asp:TextBox in codebehind, the textbox
I have tried this login_div.Style(display) = none; But it's not working.how can I set
I've got a set of ASP.Net pages that display a number of asp:TextBox fields
I understand that we can set the various style attributes from code behind using
I'm using VS2010,C# to develop my ASP.NET web app, I'm going to display some
Sorry for troubling. Im trying to display the selected fields in a asp.net gridview.
I have an asp.net page which does most of the work in the c#
I'm working with an already built ASP.Net custom date control, it seems pretty simple,
How to set the default style for a type in code-behind e.g. for: <ScaleTransform
When hovering over an item in a list, how can I set a property

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.