ASP Webforms 2.0
Asp 2 configuration (appsettings, health monitoring etc)
Compilation
- Asp.net has 2 types of compilation:
- Project compilation - msbuild .csproj and the .cs/embedded resources into a dll.
- Runtime compilation - not msbuild. Parses .aspx into codeDOM, then dlls (which are written to temporary ASP.Net Files folder)
- Precompilation (publish) - is a wrapper around runtime compilation.
- Publish Website (or aspnet_compiler.exe -p c:\src -v /myvirtual).
- Aspx markup is compiled by default. Use -u (updateable) so aspx/ascx not compiled.
- New dll names are created by default. Use -fixednames.
- One dll per page by default. Use WDP aspnet_merge.exe to make one dll per folder (or -o for one dll to rule them all).
Expressions
Expression | When | Use |
---|---|---|
%= value % | Render | Not in %asp: server controls. |
%: value % | Render with HtmlEncode (.Net 4.0+) | Not in %asp: server controls. |
%# value % | After DataBind only | Can be in %asp: server controls. See here |
%$ value % | PreInit | The Expression Builders: AppSettings:, ConnectionStrings: and Resources: Can be in %asp: server controls. |
Master Pages
URL Rebasing is a problem. Use <img src="<%= ResolveClientUrl("imgs/tab2.gif") %>"
Themes and Skins
- MSDN Themes
- Themes can be applied in two ways:
- Theme = applied after control style properties, so cannot be overriden
- StyleSheetTheme = applied before control style properties, so can be overriden
- Themes can be applied
- for a site (in web.config <pages Theme="myTheme")
- on a single page (@page Theme-)
- globally in wwwroot\Aspnet_client\System_web\ or %SystemRoot%\Microsoft.NET\Framework\x\ASP.NETClientFiles\Themes
- Skin files have:
- Default skin controls: <asp;Button runat="server" BackColor="Blue" /%gt;
- Named skin controls: <asp;Button runat="server" SkinId="Red" BackColor="Red" /%gt;
These have to be refered to explicitly.
- You can dynamically change a theme only in (master)page.PreInit
Problems with themes:
- All the css files are automatically linked in- you can't do conditional stylesheet links for specific browsers or section of the site
- Themed images are supposed to have a SkinId, and the skin file contains as asp:Image.
- With authorization, your login page can be unstyled. You have to allow users="*" (in web.config location, or create an AppThemes/web.config)
- Enumerating themes is not obvious (foreach thru HostingEnvironment.VirtualPathProvider.GetDirectory("~/App_Themes").Directories )
- With precompiled websites, you can't change the theme in web.config. You have to recompile. Doh!