How do it create/access my own properties for elements in C# that I will use in JS. and how do I access properties that are avaiable in Html but don't appear to be exposed in the c# set like the border property for tables I know I can do it with styles and classes, but it seems like a limp around as opposed to the most robust way to do it. Thanks in advance.
2 Answers
The Attributes property of the WebControl base class is what you're looking for. Example:
MyControl.Attributes["myattr"] = "examplevalue";
2 Comments
The most robust as well as the most correct way of doing it is though CssClass property and a class defined inside a .css file.
One reason to this is that if you have a designer who only touches CSS, they can change styles without touching your C# source code. If you don't have a designated CSS person, layer separation is still beneficial - just imagine looking though source code to change border color.
Separating CSS, source code and JS as much as you can is the advisable practice.