Click here to Skip to main content
15,890,609 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: hash and salt Pin
leckey11-Jul-07 15:00
leckey11-Jul-07 15:00 
GeneralRe: hash and salt Pin
Sathesh Sakthivel11-Jul-07 17:58
Sathesh Sakthivel11-Jul-07 17:58 
QuestionChart Refresh Problem Pin
Hyland Computer Systems11-Jul-07 8:10
Hyland Computer Systems11-Jul-07 8:10 
AnswerRe: Chart Refresh Problem Pin
Michael Sync11-Jul-07 8:22
Michael Sync11-Jul-07 8:22 
GeneralRe: Chart Refresh Problem Pin
Hyland Computer Systems12-Jul-07 5:44
Hyland Computer Systems12-Jul-07 5:44 
QuestionOpen New window with some parameter Pin
Sarfaraj Ahmed11-Jul-07 4:59
Sarfaraj Ahmed11-Jul-07 4:59 
AnswerRe: Open New window with some parameter Pin
Michael Sync11-Jul-07 8:13
Michael Sync11-Jul-07 8:13 
QuestionChanging skins at runtime [modified] Pin
dandy7211-Jul-07 4:19
dandy7211-Jul-07 4:19 
I'm confused.

I'm new to ASP.NET, but already have enough experience with plain old HTML/classic ASP to get by (I'm more of a C/C++ guy trying to expand my horizons).

I have page that performs some database operations, with an asp:label that shows the result either in green or red text to indicate success or failure. I've defined two CSS classes:

.clsMessageSuccess<br />
{<br />
	color: Green;<br />
}<br />
.clsMessageFailure<br />
{<br />
	color: Red;<br />
}

Then at runtime, depending on the result of the database operation, I change my label's CssClass property to either clsMessageSuccess or clsMessageFailure. Works great.

Now I'm trying to revisit this and do things "the ASP.NET way" using themes and skins. I've defined the following in my .skin file:

<asp:Label runat="server" SkinID="sknResultLabelSuccess" ForeColor="Green" /><br />
<asp:Label runat="server" SkinID="sknResultLabelFailure" ForeColor="Red" />


I thought I'd simply be able to replace my label's SkinID property at runtime like I'm currently doing for CssClass. No such luck:

"The 'SkinId' property can only be set in or before the Page_PreInit event for static controls. For dynamic controls, set the property before adding it to the Controls collection."

Great. I could understand why, and it looks my approach is plain wrong, but what I don't understand then is how it should be done "properly". I could just forget about the whole skins idead and just change the label's ForeColor property instead of its SkinID (which apparently isn't allowed), but this goes against the very nature of code/styling separation. What if I also wanted to make the text bold? I'm not going to start changing multiple properties every place I'm currently trying to replace the SkinID.

Why not stick with replacing CssStyle? Because my master page uses one .css file, and it's getting quite long. It contains different sections that are only used by specific pages. I want to break that out into multiple .css files and *only* include the required files in the pages that need them. However, the master page is the one containing the head tag (and closes it), so I can't include additional .css files in other aspx files (or if I can, I haven't found out how). Traditionally, in classic ASP, I've been able to include multiple css files without any issue (eg, I have one basic css file that applies to all pages--which I've now put in the master page--and other files that apply only to the page in question). What's the proper way to do this in ASP.NET?

I'm starting to dislike the way ASP.NET does some things. Themes/skin files sound great in theory, but then looking at the HTML generated, I see it takes the attributes defined in skin files and applying them directly as style attributes to individual controls. Awesome. So CSS files made us take styling out of the HTML, but then skins adds them back?


-- modified at 10:24 Wednesday 11th July, 2007
AnswerRe: Changing skins at runtime Pin
Michael Sync11-Jul-07 8:10
Michael Sync11-Jul-07 8:10 
GeneralRe: Changing skins at runtime Pin
dandy7212-Jul-07 4:27
dandy7212-Jul-07 4:27 
QuestionDisplay Multiple Columns in a List Box Pin
kibromg11-Jul-07 4:00
kibromg11-Jul-07 4:00 
AnswerRe: Display Multiple Columns in a List Box Pin
Michael Sync11-Jul-07 7:59
Michael Sync11-Jul-07 7:59 
QuestionGridView Pin
.NET- India 11-Jul-07 3:49
.NET- India 11-Jul-07 3:49 
AnswerRe: GridView Pin
Michael Sync11-Jul-07 7:57
Michael Sync11-Jul-07 7:57 
QuestionFocus and Gridview Pin
.NET- India 11-Jul-07 3:48
.NET- India 11-Jul-07 3:48 
AnswerRe: Focus and Gridview Pin
Michael Sync11-Jul-07 7:54
Michael Sync11-Jul-07 7:54 
QuestionGridView and DetailsView Pin
Sarfaraj Ahmed11-Jul-07 3:42
Sarfaraj Ahmed11-Jul-07 3:42 
AnswerRe: GridView and DetailsView Pin
Vasudevan Deepak Kumar11-Jul-07 3:46
Vasudevan Deepak Kumar11-Jul-07 3:46 
QuestionERROR:The test form is only available for requests from the local machine Pin
Sebastian T Xavier11-Jul-07 3:31
Sebastian T Xavier11-Jul-07 3:31 
AnswerRe: ERROR:The test form is only available for requests from the local machine Pin
Vasudevan Deepak Kumar11-Jul-07 3:44
Vasudevan Deepak Kumar11-Jul-07 3:44 
GeneralRe: ERROR:The test form is only available for requests from the local machine Pin
Sebastian T Xavier11-Jul-07 3:55
Sebastian T Xavier11-Jul-07 3:55 
QuestionExport a table to a csv Pin
Senseicads11-Jul-07 3:10
Senseicads11-Jul-07 3:10 
AnswerRe: Export a table to a csv Pin
Vasudevan Deepak Kumar11-Jul-07 3:24
Vasudevan Deepak Kumar11-Jul-07 3:24 
GeneralRe: Export a table to a csv Pin
Senseicads11-Jul-07 4:02
Senseicads11-Jul-07 4:02 
GeneralRe: Export a table to a csv Pin
ednrgc11-Jul-07 5:29
ednrgc11-Jul-07 5:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.