How to create server controls at runtime

Platform: ASP.NET|Category: Controls

Here is an example of creating a HyperLink control in code.

VB.NET

Dim hpl As New HyperLink()
hpl.Text='Text'
hpl.NavigateUrl='http://www.syncfusion.com'’
hpl.ID='theID'
Page.Controls(1).Controls.Add(hpl)
C#
HyperLink  hpl = new HyperLink();
hpl.Text='Text';
hpl.NavigateUrl='http://www.syncfusion.com';
hpl.ID='theID';
Page.Controls[1].Controls.Add(hpl);