can i use custom attributes with linkbutton?
like this:
var linkb= new LinkButton();
linkb.ID = "myLinkButton";
linkb.Text = "x";
linkb.Click += linkbuttonClicked;
linkb.Attributes["data-id"] = "DataId";
linkb.CssClass = "lb";
MyPanel.Controls.Add(linkb);
Can i do something like this onClick?
var thisButton= (LinkButton) sender;
var test = thisButton.Attributes["data-id"]);
As far as I know, you can do that in ASP.NET 4.0, the attribute and value will be saved in the viewstate and persist across postbacks.
But, as it persists only in the viewstate, if you change its value client-side with some js/jquery, the new value will not be sent to the server on postback and will not persist.