Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting SkinID of control then retrieving control properties

Status
Not open for further replies.

ochjings1

Programmer
May 4, 2005
4
0
0
GB
c# and ASP.NET

When setting a SkinID which contains a property such as BackColor:

TableCell thisCell = new TableCell;
thisCell.SkinID = "redSkin";

...If I attempt to access the property after this:

Color cellColor = thisCell.BackColor;

...cellColor is null. I'm assuming that either the SkinIDs are applied over and above the basic properties of controls so are disconnected, or the Skin is applied at a seperate time when rendering the page. Is there any way to access this BackColor value?

Any help appreciated,
Steve
 
I can see a couple of things here that could be an issue

Code:
TableCell thisCell = new TableCell;
thisCell.SkinID = "redSkin";

System.Web.UI.WebControls.TableCell
doesnt have a SkinID parameter

I would imagine that you also need a parenthesis after the new TableCell

And lastly, you are setting a SkinID property to a string, and then retrieving a totally different parameter back from the object, and trying to retrieve a colour that has not yet been defined.

K

 
Thanks for the post - yeah probably should have copied the code in a little more carefully, hence the (). TableCell doesn't have a SkinID parameter but WebControl does so no problem there - also the Skin itself applies fine.

What I'm interested in is the "you are setting a SkinID property to a string, and then retrieving a totally different parameter back from the object, and trying to retrieve a colour that has not yet been defined."

The Skin itself contains a BackColor property, which I assumed would set the TableCell's BackColor property. At what point during the code execution can I (if ever) access the TableCell's BackColor property - when is the Skin actually applied and when would I be able to access this BackColor property that's set in the Skin?

Thanks,
Steve
 
Ah I dont have 2005.

But from google, you have a .skin file, and in there you define the skin that you wish the control to have. This will be applied (I am guessing) At runtime when the control is rendered to the page, and so, like a style element in old html, override whatever is in the background-color.

But, I am guessing most of this,

Theres a brief example at the link below

Hth
K
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top