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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T18:30:55+00:00 2026-05-10T18:30:55+00:00

What is the best way to access an ASP.NET HiddenField control that is embedded

  • 0

What is the best way to access an ASP.NET HiddenField control that is embedded in an ASP.NET PlaceHolder control through JavaScript? The Visible attribute is set to false in the initial page load and can changed via an AJAX callback.

Here is my current source code:

<script language='javascript' type='text/javascript'>     function AccessMyHiddenField()     {         var HiddenValue = document.getElementById('<%= MyHiddenField.ClientID %>').value;          //do my thing thing.....     } </script> <asp:PlaceHolder ID='MyPlaceHolder' runat='server' Visible='false'>     <asp:HiddenField ID='MyHiddenField' runat='server' /> </asp:PlaceHolder> 

EDIT: How do I set the style for a div tag in the ascx code behind in C#? This is the description from the code behind: CssStyleCollection HtmlControl.Style

UPDATE: I replaced the asp:hiddenfield with an asp:label and I am getting an ‘undefined’ when I display the HiddenValue variable in a alert box. How would I resolve this.

UPDATE 2: I went ahead and refactored the code, I replaced the hidden field control with a text box control and set the style to ‘display: none;’. I also removed the JavaScript function (it was used by a CustomValidator control) and replaced it with a RequiredFieldValidator control.

  • 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. 2026-05-10T18:30:55+00:00Added an answer on May 10, 2026 at 6:30 pm

    My understanding is if you set controls.Visible = false during initial page load, it doesn’t get rendered in the client response. My suggestion to solve your problem is

    1. Don’t use placeholder, judging from the scenario, you don’t really need a placeholder, unless you need to dynamically add controls on the server side. Use div, without runat=server. You can always controls the visiblity of that div using css.
    2. If you need to add controls dynamically later, use placeholder, but don’t set visible = false. Placeholder won’t have any display anyway, Set the visibility of that placeholder using css. Here’s how to do it programmactically :

      placeholderId.Attributes[‘style’] = ‘display:none’;

    Anyway, as other have stated, your problems occurs because once you set control.visible = false, it doesn’t get rendered in the client response.

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

Sidebar

Related Questions

On an ASP.NET MVC website, what's the best way to implement access logging? I
Bascially I want to know the best way to hide/show an ASP.NET control from
Using ASP.net, is there a recommended best way to access a particular field of
What's the best way to handle data entered through dynamically generated controls in ASP.NET?
Greetings, Trying to sort through the best way to provide access to my Entity
I have a web application in asp.net and C# that must access a remote
What is the best way for me to build a control that will kinda
I'm using ASP.NET MVC with Razor syntax. I'm trying to find the best way
What's the best way to acces .resx files in a Http Handler in ASP.NET?
I have an ASP.NET MVC based application that allows different levels of access depending

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.