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#.
Below is the code that can be called on some events like page load or onload or even some user action like onclick.
protected void add_button(Button btn)
{
try
{
panel1.Controls.Add(btn); // Add the control to the container on a page
}
catch (Exception ee)
{
lblError.Text = ee.Message.ToString();
}
}