How to add controls dynamically to ASP.NET form?

后端 未结 6 1793
说谎
说谎 2021-01-12 02:16

I do not know how to add controls dynamically to the form using C# .net. Can anyone help me? I know this with vb.net but I need to know the syntax in C#.

6条回答
  •  旧巷少年郎
    2021-01-12 02:31

    Please see the below sample

    lets say forms name is frmMain.

    Button btnSave = New Button();
    frmMain.Controls.Add(btnSave)
    

提交回复
热议问题