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

The Archive Base Latest Questions

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

How can I access the value of a control (in CodeBehind) that was created

  • 0

How can I access the value of a control (in CodeBehind) that was created by JavaScript dynamically?

I created the controls dynamically by using the following code:

var counter = 0;
var words;
var foo;//span tag 

function add(i) {
    var counter = 0;
    var words;
    var foo;//span tag asp in page where the controls to be added

    if (i == 'ad') {
        counter++;
        //Create an input type dynamically.
        foo = document.getElementById("dynamic")
        tbnam = document.createElement("input")  //textbox
        tbdes = document.createElement("input")  //textbox
        lbnam = document.createElement("Label")
        lbdes = document.createElement("Label")
        before = document.createElement('br')
        after = document.createElement('br')

        //Assign different attributes to the element.
        wordsnam = document.createTextNode("Item")
        wordsdes = document.createTextNode("Descrip")
        tbnam.setAttribute("type", "TextBox");
        tbdes.setAttribute("type", "TextBox");
        tbnam.setAttribute("Id", "tbdynamicnam" + counter);
        tbdes.setAttribute("Id", "tbdynamicdes" + counter);
        lbnam.setAttribute("Id", "lbdynamicnam" + counter);
        lbdes.setAttribute("Id", "lbdynamicdes" + counter);
        before.setAttribute("Id", "bf" + counter);
        after.setAttribute("Id", "af" + counter);

        lbnam.appendChild(wordsnam)
        lbdes.appendChild(wordsdes)

        //Append the element in page (in span).

        foo.appendChild(before);
        foo.appendChild(lbnam);
        foo.appendChild(tbnam);
        foo.appendChild(lbdes);
        foo.appendChild(tbdes);
        foo.appendChild(after);            
    }
}
  • 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-01T19:33:42+00:00Added an answer on June 1, 2026 at 7:33 pm

    When the form is submitted it will be in the Request.Form collection, you can access it easiest in the Request object which will check all collections(QueryString, Form, Cookies, and ServerVariables)

    JavaScript:

    tbnam = document.createElement("input")  //textbox       
    tbnam.setAttribute("type", "TextBox");       
    tbnam.setAttribute("Id", "tbdynamicnam" + counter);
    tbnam.setAttribute("name", "tbdynamicnam" + counter);
    

    Code-behind:

    string newval = Request["newelementname"];
    

    As mentioned below by James Montagne, you will need a form element name.

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

Sidebar

Related Questions

I can't figure out how to access the value of a control in a
I need to create a custom constraint annotation which can access the value of
Hey, I can't seem to access the returned value from a method I called
In php how can I access an array's values without using square brackets around
I can access the database either from a .NET program (using ODBC) or through
I can access Spring beans in my Servlets using WebApplicationContext springContext = WebApplicationContextUtils.getWebApplicationContext(getServletContext()); in
We can access the valueStack (and other objects of ActionContext ) using OGNL but
Can anyone let me know how can access an element of a list that
I have a user control that I'm adding to a webpage dynamically. The ascx
How can we access the model's property name when using EditorFor() with a template

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.