Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

In ASP.NET Web Forms, setting Visible="false" on an <asp:TextBox> prevents the TextBox from being rendered into the response. Its HTML is not sent to the browser, so there is no element for browser JavaScript to select. This is server-side omission—not CSS such as display:none.

Why is an asp:TextBox with Visible=”false” missing?

The Visible property controls whether a server control is sent to the browser. When it is false, ASP.NET does not emit the TextBox’s HTML for that request. A normal Web Forms TextBox would ordinarily render as an HTML text input, but this setting suppresses that output entirely.

For example:

<asp:TextBox ID="SecretValue" runat="server" Visible="false" Text="server value" />

After the page is rendered, the response contains no markup for SecretValue. The value is therefore not available to client-side JavaScript through a rendered input element.

Does Visible=”false” mean display:none?

No. CSS hiding applies to markup that has already been sent to the browser; Visible="false" prevents the control’s markup from being sent at all. If you need client-side code to find or reveal an element, the element must be rendered to the page in the first place.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Which approach should you use?

Choose based on whether the value needs to be displayed, posted, or omitted from the response:

Approach HTML emitted? Available to browser JavaScript? Posts back? Client can change the value? Use it when
Visible="false" No TextBox markup No rendered TextBox to access No TextBox value is submitted There is no rendered TextBox to edit The control should be omitted from the response.
ReadOnly="true" Yes, as a visible TextBox Yes Yes; the value is sent on postback The user cannot edit it through the read-only field, though client-side data should not be treated as trusted The value should be displayed but not editable as a normal input.
<asp:HiddenField> Yes, as a hidden form field Yes Yes Yes; a user can inspect and change it The value must round-trip in the form without being displayed.

Display a value without allowing ordinary edits

Use a read-only TextBox when the user should see the value and the page should submit it on postback:

<asp:TextBox ID="DisplayValue" runat="server" ReadOnly="true" Text="server value" />

Microsoft documents that a read-only TextBox value is sent to the server on postback, while the server does not process it as editable input. Do not rely on a value submitted by the browser as proof of authorization or integrity.

Round-trip a value without displaying it

Use a HiddenField when the form needs to carry a value back to the server:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
<asp:HiddenField ID="RoundTripValue" runat="server" Value="server value" />

A hidden field is still client-side form data: users can inspect and modify it. Validate any submitted value and keep security-sensitive state on the server rather than trusting the field.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What this means for Web Forms pages

This behavior is for ASP.NET Web Forms server controls, including the .NET Framework documentation for TextBox. It is not a statement about ASP.NET Core Razor syntax. Also, a TextBox’s rendered HTML depends on its mode; for example, multiline and password TextBoxes do not use the same output as an ordinary single-line text input.

Microsoft’s server-controls guide describes Visible as a server-side visibility setting: an invisible control is not sent to the browser. The companion Web Forms chapter explains the TextBox rendering behavior. For the alternatives, see Microsoft’s documentation on read-only TextBoxes and HiddenField controls.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.