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);

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.