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

The Archive Base Latest Questions

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

I am adding controls dynamically to my page on the basis on a condition.There’s

  • 0

I am adding controls dynamically to my page on the basis on a condition.There’s a button in these controls, to which i have attached an event handler as well for click event.Now in this event handler, i am trying to access my dynamically generated controls, but getting an exception. Here’s my code:

protected void Page_Load(object sender, EventArgs e)
        {
            String Method = Request.QueryString["Method"];
            String Tag = Request.QueryString["Tag"];


            if (Method=="ADD" && Tag=="METHOD")
            {

                //6
            TableCell cell11 = new TableCell();
            cell11.Text = "NEXTLEVEL";

            TableCell cell12 = new TableCell();
            TextBox txt6 = new TextBox();
            txt6.ID = "txt6";
            cell12.Controls.Add(txt6);

            TableRow row6 = new TableRow();
            row6.Cells.Add(cell11);
            row6.Cells.Add(cell12);

            container.Rows.Add(row6);
                TableCell cell14 = new TableCell();
                Button submit = new Button();
                submit.ID = "SubmitButton";
                submit.Text = "Submit";
                submit.Click += new EventHandler(submit_Click);

                cell14.Controls.Add(submit);

                TableRow row7 = new TableRow();

                row7.Cells.Add(cell14);

                container.Rows.Add(row7);
            }

void submit_Click(object sender, EventArgs e)
        {
            ModifySessionAnalyzer msa = new ModifySessionAnalyzer();
            TextBox txt6= (TextBox)Page.FindControl("txt6") as TextBox;
            ##String message = txt6.Text;##

        }
  • 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:08:12+00:00Added an answer on June 3, 2026 at 3:08 am
    TableCell cell12 = new TableCell();
    TextBox txt6 = new TextBox();
    txt6.ID = "txt6";
    cell12.Controls.Add(new TextBox());
    

    This is wrong, you are not adding the txt6 control to the cell, instead you are adding a new textBox…

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

Sidebar

Related Questions

I'm adding HTML controls dynamically using java script. For instance, I have one button
i have a aspx page on it i'm dynamically adding the web user controls
I have an aspx page that dynamically loads user controls: there is an UpdatePanel
I have a form on my page and am dynamically adding controls to the
I have a Panel and I am adding controls inside this panel. But there
I have a .aspx page that loads three separate .ascx controls to represent adding,
I'm listing some controls at my web page dynamically, either I'm adding newline with
I am adding HTML input controls on the page dynamically via a add text
I am adding labels dynamically to a page, there are a few labels that
Have a page that adds controls dynamically. Control state is being retrieved from database

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.