November 2010 Entries

Combine and compress javascript and css files in ASP.Net MVC

Goal: When loading js or css files, combine all the js files into one and all css files into one file respectively when rendering to improve on performance. Also compress if need be on the fly. In this example we use many css files and even more js files to organize the ASP.Net Mvc web app into manageable pieces. The reason for the separation is mainly because it gives the team the ability to work on different part of the web app by working on the affected css or js files. It also helps to decide ......

Loading CSS stylesheet for ascx ASP.Net user control

Goal: For performance reasons you want to load a piece of CSS only for the ascx file to which it applies. You do not want to embed the style as you cannot do this in ASP.Net ascx user controls. ASP.Net will render the style tag as HTML text. Solution: Some folks use the Page.Header.Controls. Add to add the stylesheet link in the ascx page or in the code behind. Not needed, you may specify a "link" tag in the ascx file, no need to specify "head" tag or anything else, just the link tag itself: <link ......

How to store arbitrary data in the DOM using jQuery

Goal: Storing arbitrary data inside the DOM Issue: Storing data : $('selector').attr('alt', 'my data'); Retrieving data: $('selector').attr('alt'); The ALT attribute is designed to be an alternative text description. For images the ALT text displays before the image is loaded. ALT is a required element for images and can only be used for image tags because its specific purpose is to describe images.So therefore, "alt" is an HTML attribute meant to give the tag meaning and not to store data. Also ......

Images do not appear on my SSR report

Problem: You dynamically (or not) set the URL for the image you want to display in an SSRS report but it does not display the image (red x). The reason: SSRS access the images folder with anonymous access which is be default not allowed in IIS7 (not sure about IIS6 and prior versions). The solution: Make sure anonymous access is allowed to that images folder where the image resides that you are referencing via URL in SSRS Report. Also make sure that anonymous access is set to ENABLED in IIS for that ......

Seting select index in jQuery

$('#myselect option:eq(1)').attr('selected', 'selected');

This will select the first option


To deslect it do not use null ( as in attr('selected', null)) but rather use removeAttr as in

$('#myselect option:eq(1)').removeAttr('selected');