0

Please dont give me immediately downvotes, I have same question as asked here, how to assign values to textbox in another method which was dynamically created in c sharp, but FindControl method doesnt exist in current context.

Here is my code

private void btnOkreni_Click(object sender, EventArgs e)
{
        TextBox txt = new TextBox();
        txt.Name = "txtBoxOpis";
        txt.Text = izabrana[0].Opis;
        Controls.Add(txt);
}

private void btnSledeca_Click(object sender, EventArgs e)
{
    foreach (Karta k in izabrana)
        {
            if (k == izabrana[0])
            {
                continue;
            }
            txtBoxPojam.Text = k.Pojam;

            //((TextBox)FindControl("txtBoxOpis")).Text = k.Opis;
         }
}
Community
  • 1
  • 1
mike_cus
  • 67
  • 1
  • 10
  • What happens at the commented line of code? What issue or error you are facing? Did you go thru the link shared by @pinkfloydx33? – Chetan Mar 13 '17 at 00:27

1 Answers1

0

make TextBox txt; as public variable , after that initialize it with txt = new TextBox , than you are able to get this everywhere within the main class

EAK TEAM
  • 5,726
  • 4
  • 30
  • 52