Why are ASP.NET themes necessary when we have CSS already? - asp.net

You can specify CssClass in server controls and your ASP.NET page will generate the style attribute for the control.
You can also specify an external CSS file in the ASP.NET page just as you would in an ordinary HTML page.
You can also write a tag in the ASP.NET page header section just as you would for an ordinary HTML page.
Then why are ASP.NET Themes necessary?

Don't confuse ASP.NET Themes with ASP.NET Skins. I've explained them here:
The Theme system in ASP.NET does not compete with CSS, instead it's a system that's meant to make it easier to allow users to choose the stylesheets that are applied to the site.
The idea being that you'd create a "BoringBlue.css" stylesheet and associated artwork, then make a few changes and create a new one called "HotPink.css". Rather than doing the work to generate the markup that enables or disables the page's style <link> elements ASP.NET Themes will do this heavy lifting for you.
However, ASP.NET Web Forms Web Controls were originally made during the IE6 love-in at Microsoft (back when they pretended Firefox didn't exist, so this is around 2004-2005) so they don't make heavy use of CSS, many controls render presentational attributes, such as bgcolor. "ASP.NET Skins" are a way to control the colors and other presentational settings of WebControls (note, not HtmlControls). ASP.NET Themes provide you with a way to choose which ASP.NET Skin is also applied, in addition to CSS stylesheets.
Note that under ASP.NET MVC, Themes and Skins are completely obsolete as the framework no-longer renders any complex markup, returning complete control to the developer. Finally, no more gimmicks - I haven't really come across a "let the user set the color scheme"-site since people stopped using phpNuke around 2007.

Related

When developing custom SharePoint application pages, should I use SharePoint web controls instead of ASP.NET controls?

I'd like to create a couple of custom application pages with native SharePoint 2010 look and feel. So far, I've been drag-and-dropping ASP.NET components into user controls in VS2010, then applying SharePoint's css via CssClass properties.
Now I've noticed that SharePoint aspx pages internally use a lot of SharePoint tags like <SharePoint:UIVersionedContent>, <SharePoint:SPLinkButton>, <wssawc:InputFormTextBox> etc. instead of the usual ASP.NET controls (like <asp:LinkButton>). However, there is no way known to me to create SharePoint pages with the native components other than manually dissecting existing aspx pages and trying to figure what mysterious tags and elements SharePoint uses, then try to emulate this in my own page, line by line.
Should I be worried that I'm using normal ASP.NET tags instead of <SharePoint:*> tags? Is there a better way to create SharePoint-friendly native custom pages other than manually coding everything through trial-and-error?
You can use standard ASP.NET control (or any other) in SharePoint pages however you will need to customize them by CCS styles to look SharePoint-like. It's possible but sometimes time consuming.
On the other hand you can use SharePoint controls. They have SharePoint look out of the box and are prepared for the use in SharePoint. E.g. they can use SharePoint objects directly as data sources etc. Moreover it would be hard to implement some SharePoint controls as PeoplePicker using standard ASP.NET controls, CCS and code-behind.

Combining ASP.NET controls with CSS

I am relatively new to website design and specifically working in ASP.NET, i am using CSS to style my site, but when i use ASP.NET Controls like GridView, Navigation controls, etc ...
they are messed up by the style sheets, and you can't see that until you run the website, because the controls are translated to HTML and so affected by CSS in a way that you can't predict, how to solve this, and is there a better way to layout and desgin sites in ASP.NET.
You can use ControlAdapters or better use ASP.NET MVC
A great method that's worked well for me is to create Skins for your ASP.NET controls.
http://msdn.microsoft.com/en-us/library/ykzx33wh.aspx
http://www.asp.net/web-forms/videos/how-do-i/how-do-i-use-skins-with-css-for-a-flexible-and-maintainable-aspnet-web-site
After getting my skins and CSS classes created for the different pieces of my ASP.NET controls I'll then run my app in a browser with good developer tools, Google Chrome has a stellar set of dev tools that allow you to modify your css classes and styles right in the page so you can see the results immediately. I'll then update my Skin CSS classes to match the styles I created using the browser dev tool.

How can ASP.NET generate HTML5 code?

I'm feeling a bit lost with my question about HTML5 code generation, and despite having put some efforts into my research I don't really feel much wiser.
I use VS2010 for the creation of ASP.NET pages, and I do know that there is an (unofficial) "Web Standards Update" for VS2010 SP1. Using this update I can change the settings of the "Target Schema for Validation" in the ASPX editor window to HTML5. The new elements / tags and semantics are then available via Intellisense, and I can nicely code away manually using all the fancy new stuff.
What I don't understand is how to get something like the ASP.NET controls to generate HTML5 code (where it makes sense). Is this at all possible or am I completely going in the wrong direction here? I would have expected that I do not have to "hand code" HTML5 as long as I use the existing controls (which tend to generate a lot of JavaScript in the background when the page is delivered to the client's browser).
Thanks in advance for a clarifying answer
G.
Some controls generate slightly different dialects of HTML based on the particular User-Agent. However, not all of them know about HTML 5 yet, and there's no specific property to enable HTML 5 generation, just as there isn't a property to enable other dialects of HTML.
If you want to generate HTML 5, you can do one of three things:
Create a new control that overrides the existing one, and either use it directly or replace the original with it everywhere in your app with tag mapping
Create a control adapter and modify the control's output as it's generated
Create a custom control
The controls you are referring in ASP.NET are what is commonly known as "webforms". They are basically server side controls that generates the javascript code needed to postback the data to the server, mantain the state of the controls between postbacks, and stuff like that. As you said, those controls generate too much code and a excessive number of roundtrips to the server, so it is not very recommended to use webforms.
HTML5 is mainly client side, so it has very little to do with the webforms server controls. It's a different approach than the old ASP.NET webforms. Because of this, ASP.NET is including on its newer versions the MVC framework, the razor engine, JQuery and another javascriprt libraries. MVC includes some helper classes and templates that helps you generating the client code, and many other features to support HTML5 enabled webs. So, I would recommend to start reading about it.
Anyway, now that jquery is fully integrated in Visual Studio, javascript coding is not so difficult.

How to change the look and feel of ASP.NET server controls?

Is it possible to change the default template of each ASP.NET server control? In WPF and Silverlight, each control is supposed to be lookless, so the developer can provide a user-defined control template to change how the control looks. If, for example, I want to use an outer and inner square/rectangle other than an outer and inner circle in a RadioButton, how do I accomplish that?
Don't have much experience with ASP but we used to work with Prado a lot (a PHP framework that behaves much like ASP .NET).
I would say the easiest thing to do is assign a CSS class to the component, which you should be able to do to any ASP .NET component and then simply use CSS to style the component.
At the end of the day, its all spat out to the browser as HTML anyway, so there's no real reason why you couldn't style it using CSS.
I recommend you don't use the standard CSS classes, unless you want all instances of a particular component to the look the same for your application.
We write a lot of Ajax apps and this is what we do.
ASP.NET has support for Themes and Skins. You can use a combination of skins and CSS (packaged up into a theme for convenience) to apply some styles to your controls. However, different browsers on different operating systems may render various controls slightly differently (for example take a look at how radio buttons are rendered). I'm not sure how much control you'll have over that behavior.

Templates or css skins for the asp.net membership login control?

I want to style the asp.net membership login control and I am too lazy to handcraft a professional looking one.
I couldn't find ready made css styles for the login control. Are there any available on the web?
The easiest thing to do would be extend the look of your current style sheet. More than likely any style sheet found on the web would look out of place in the context of your site.
That being said if you want a clean looking starting point with a lot of good built in styles take a look at Google Blueprint specifically their form demo page.

Resources