ASP.NET control rendering HTML attributes -
i have custom control in asp.net web forms project inherits system.web.ui.control
.
i want add attributes in markup not correspond properties of control e.g.
<mycontrols:hyperlink runat=server custom-client-side-attr="1"></<mycontrols:hyperlink>
the problem having exception
type 'mycontrols.hyperlink' not have public property named 'custom-client-side-attr'.
i have tried persistchildren(false)
, not fix it. has been while since have been in depths of asp.net web forms , cannot remember how done.
you have add in server-code:
hl1.attributes["custom-client-side-attr"] = "1";
you can still in markup - you'd have prior the declaration:
<% hl1.attributes["custom-client-side-attr"] = "1"; %> <mycontrols:hyperlink id="hl1" runat=server custom-client-side-attr="1"></<mycontrols:hyperlink>
Comments
Post a Comment