Anand Patel
Anand Patel

Reputation: 6431

How to add hyperlink control items to a ASP.net ListBox control?

I want to add multiple hyperlink control items to a asp.net listbox control. I have written below code but it is not generating required output.

lstBoxAttachments.Controls.Add(new HyperLink() { Text = someText, NavigateUrl = someURL });

Any help would be appreciated.

Upvotes: 1

Views: 2295

Answers (1)

Stephen M. Redd
Stephen M. Redd

Reputation: 5428

A list box cannot contain hyperlinks. This is a limitation of HTML, not specific to asp.net.

Try using a repeater control instead.

Upvotes: 2

Related Questions