Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to provide 'data-toggle="modal"' from code behind C#

Tags:

c#

asp.net

I have a Hyperlink my code, for which I want to provide "data-toggle"

HyperLink lnk = new HyperLink();
lnk.NavigateUrl = "somelink";
lnk.?? here I don't know how to give "data-toggle"

So that at the end I can have a link in the page as below:

 <a data-toggle="modal" href="somelink"></a>
like image 560
Kamran Avatar asked Jul 05 '26 16:07

Kamran


1 Answers

You can use Attributes collection, you can find more in How to: Set HTML Attributes for Controls in ASP.NET Web Pages

lnk.Attributes["data-toggle"] = "modal";
like image 71
Adil Avatar answered Jul 07 '26 05:07

Adil