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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:54:22+00:00 2026-06-03T03:54:22+00:00

I have a asp.net usercontrol (.ascx). the user control has a HTML hidden field.

  • 0

I have a asp.net usercontrol (.ascx). the user control has a HTML hidden field.

<input id="HiddenField1" type="hidden" runat="server" />

the user control fires a HTML window pop up, users enter several values in the pop up, then after the pop up is closed a string value is saved in that hidden field.

document.getElementById("HiddenField1").value = windowResult;

finally the back end code of the user control does some tasks by picking up the string value from the hidden field.

string[] nameValuePair = new string[2];
nameValuePair = HiddenField1.Value.Split('%');   

The problem is the document.getElementById(“HiddenField1”) is failing while execution. because when I use the user control in a web page, the ID of the control becomes [my usercontrol name] + $ + [hidden field name]. (for ex. ctrl_TaxonomyTree1$HiddenField1)

Since the user control will be populated dynamically, I can not always know the name of the instance.

Is there any way to sort this out?

  • 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-03T03:54:23+00:00Added an answer on June 3, 2026 at 3:54 am

    EDIT

    The Controls collection cannot be modified because the control contains code blocks (i.e. <% … %>)
    Error is occuring because of this

    <head id="head1" runat="server">
      <script>
       document.getElementById('<%=HiddenField1.ClientID %>').value = windowResult; 
      </script>    
    </head>
    

    When you add the runat=”server” attribute to the tag, the runtime treats it as an HtmlHead control.

    EDIT

    Solution for the error which you provided in comment

    Removed JavaScript from the head section of page and added it to the body of the page and got it working

    Check : Article for Error

    it will be

    document.getElementById('<%=HiddenField1.ClientID %>').value = windowResult; 
    

    because in hidden filed is on server side you neeed to get client id of the filed to get the value in your javascript..

    For Asp.net 4.0

    If you are using Asp.net 4.0 version than have look to this : ASP.NET 4.0 Client ID Feature

    Control.ClientIDMode Property -Gets or sets the algorithm that is used to generate the value of the ClientID property.

    AutoID
    The ClientID value is generated by concatenating the ID values of each parent naming container with the ID value of the control. In data-binding scenarios where multiple instances of a control are rendered, an incrementing value is inserted in front of the control’s ID value. Each segment is separated by an underscore character (_). This algorithm was used in versions of ASP.NET earlier than ASP.NET 4.

    Static
    The ClientID value is set to the value of the ID property. If the control is a naming container, the control is used as the top of the hierarchy of naming containers for any controls that it contains.

    Predictable
    This algorithm is used for controls that are in data-bound controls. The ClientID value is generated by concatenating the ClientID value of the parent naming container with the ID value of the control. If the control is a data-bound control that generates multiple rows, the value of the data field specified in the ClientIDRowSuffix property is added at the end. For the GridView control, multiple data fields can be specified. If the ClientIDRowSuffix property is blank, a sequential number is added at the end instead of a data-field value. This number begins at zero and is incremented by 1 for each row. Each segment is separated by an underscore character (_).

    Inherit
    The control inherits the ClientIDMode setting of its NamingContainer control.

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

Sidebar

Related Questions

I have an ASP.NET user control (.ascx file). In this user control I want
I have an asp.net user control, userControl1.ascx, and another user control, userControl2.ascx. userControl2 is
I have a simple asp.net user control: <%@ Control Language=C# AutoEventWireup=true CodeBehind=QueryDefinitionItem.ascx.cs Inherits=xxx.UserControls.QueryDefinitionItem %>
I have constructed an ASP.NET user control Box.ascx wtih the following code. <div id=divContent
I have a UserControl in my Asp.net project that has a public property. I
I have an ASP.NET user control that contains a text box control and a
I have a ASP.NET user control which hosts a 'HtmlImage'. The src attribute is
I have an asp.net user control on which I want to use jquery ajax.
We have created a User Control for ASP.Net. At any one time, a user's
I have a simple ASP.NET Web User Control. It looks like this: <%@ Control

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.