Generating fields by ASP.NET code

Asked

Viewed 267 times

0

I’m making a web application with ASP.NET and C#.

In this application I can register several items of the same type, so it has a text field and a button on the side to create new text boxes. I’ve worked with this in desktop app, but do not know how to generate the fields in the file .aspx.

How can I do that? I must do this command on .aspx or in the .cs? How can I pass the data later?

  • It is not clear what you are asked, consider reformulating your question more clearly and objectively.

  • I want to generate fields at runtime, that’s all

  • @jpklzm Let me get this straight, do you want to generate fields dynamically in the user’s browser? Please insert a piece of code that you use to generate the first field, and inform if the generated object will be "clone" of that.

  • That’s right @Leandroamorim. But I want to do it by C# or ASP.NET (I don’t know if there is such a possibility)

1 answer

1


TextBox txt = new TextBox();
txt.ID = "textBox1";
txt.Text = "helloo";
form1.Controls.Add(txt);
  • What was the reason for the negative vote in this reply? It is important to make a comment.

  • I haven’t denied that answer. I’m actually testing her.

  • 4

    Try Make more complete answers, and also screen the code write what the goal is and if so explain what each function used (or only the main ones) does, so your answer will have more quality

  • Just call this little code block in the button click method.

  • So when I try to add it asks to say that the field is runat=server. How do I do this?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.