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

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -