You can buy my programming and computer related gifts from my shop!

Posted in Uncategorized | Leave a comment

Dynamic CSS files in Master Page using C#

I have a reporting portal that serves up SSRS (SQL Server Reporting Services) reports to users. The users are from different organisations, indicated by a user group. I needed to have the front end personalised for each different organisation. The approach below loads a different CSS file depending on the user group of the logged in user. I’m using a master page solution, so the CSS is loaded in the master page file. The CSS files for each organisation are stored in a CSS folder.

If we look at a standard link to a style sheet that we would place in the head of our master page

<head runat="server">
    <link href="CSS/StyleSheet.css" type="text/css" rel="stylesheet" />

We are going to change this to what we see below

<head runat="server">
    <link id="CurrentStyleSheet" type="text/css" rel="stylesheet" runat="server"/>

You need to note three things in the above code. We need to ensure that runat=”server” is added, that there is no “href” to point to our CSS file as we be adding this in code, and we have given our link an id.

Firstly lets load the CSS file in the Page_Load event of the master page. We reference the link using its id and add the “href” attribute and value to the link (the !Page.IsPostBack stops this from being done repeatedly on every page postback).

        protected void Page_Load(object sender, EventArgs e)
            if (!Page.IsPostBack)
                CurrentStyleSheet.Attributes.Add("href", "CSS/StyleSheet.css");

This is all good, however we are still just loading one CSS file regardless. In my database I have a field that holds the CSS file name for each user group and a function getCssFile() that returns the CSS file name for the logged in user. (I’m not going to cover how that function reads the value from the database here).

So the code now becomes

        protected void Page_Load(object sender, EventArgs e)
            if (!Page.IsPostBack)
                CurrentStyleSheet.Attributes.Add("href", string.Format("CSS/{0}", getCssFile()));

This goes and gets the name of the style sheet from the database for the logged in user and inserts this into the “href” attribute.

Posted in Programming | Tagged , , , , , , | Leave a comment

Hotpoint Mistral Fridge Freezer Temperature Problems.

If your Hotpoint Fridge Freezer is reading a high temperature for the Fridge check this before you spend out any money.

After having my kitchen refitted over the last few weeks my machine was reading 24 deg C for the fridge compartment. I had moved the machine a few times and figured that something had got damaged / dislodged. What was confusing me was, how is the temperature getting that high? Even if I turned it off it wouldn’t get anywhere near that warm.

Now I don’t know much about refrigeration units, however, I guess like most electrical devices they produce heat as a by product, but enough to heat the fridge to 24 deg while the freezer was still at -20 (the freezer temp was fluctuating but only by 1 – 2 deg)?.

But one thing that can produce heat in your fridge, is the lamp…

It turns out that moving the machine about can cause the door to drop. This can mean that the door is not high enough to trigger the switch that turns off the lamp. I was unable to get the door level again, so, as the door was still sealing, I fixed with a small piece of double-sided numberplate tape and a small square of flat plastic stuck to the top of the door where the switch contacts.

Temp all back to normal within about an hour.

You can quickly test if this is your problem by removing the lamp from the inside of the fridge compartment for a short time and see if the temp drops.

I have previously replaced the thermistors in my machine when I had issues with the Freezer temperature, there are lots of examples on the internet if you need to do that.

Posted in Uncategorized | Tagged , , , , , , , , , | Leave a comment

Another new blog

My idea of funny

Posted in Uncategorized | Leave a comment

New Photo Blog

To keep everything nice and tidy I’ve started a new blog for my photography ‘stuff’.

It can be found here Photos!

Not much to see at the moment but will build over the next few weeks.

Posted in Photography | Tagged , , , | Leave a comment

Insurance Claims & Nuisance Calls From Personal Accident Companies

It’s now just about a year since I had a minor accident in my car.  I was actually stationary when a small van backed into the passenger door of my car.  The impact was about equivalent to someone kicking the door.  It goes without saying that I suffered no distress or injury or, in fact, anything that I feel I need to be compensated for.

Since the accident (in fact on the very same day) I have been receiving calls from Personal Accident Companies wanting to help get me compensation for my injuries.  I would estimate that I must have had in excess of 1000 calls, tend to have a minimum of one a day, and actually had 5 last night between 19:00 and 21:00.

I’ve gone through phases of explaining exactly what happened and that I have not suffered in any way, being deliberately rude, saying I don’t live here any more, leaving the phone to one side until they hang up… and so on.

One problem seems to be that the other party made a successful claim (not sure what for) and therefore the assumption is that I will claim too.  I had one caller suggest that even though I hadn’t suffered at all I should just put a claim in (which would be approved) and that would stop companies calling me.  So making a fraudulent claim is the suggested action of one company.

One other suggested that “maybe you’ve forgotten that you were hurt, this does happen…”, so I need to “remember” being injured.

And a third just suggested that I was an idiot as I could get “free money”.

On the bright side, one of the companies I spoke to said that you have to claim within three years, so only two more years of nuisance calls to go!

It would appear that this is just a money making scheme of insurance (they sell your information on) and personal accident companies, they both take their cuts, and the costs get passed onto us in our premiums.

I would also like to take this opportunity to thank Direct Line for selling on my details.

If you think that there should be more control over these nuisance calls Which? are running a campaign here:

Which? Calling Time on Nuisance Calls & Texts

Posted in News and politics | Tagged , , , , , , , | 2 Comments

Showing Two Different Scales on Y Axis SQL Server Reporting Services (SSRS)

Long time, no post…

I was asked to create a graph showing throughput of bags on a conveyor grouped into 5 minute intervals.  One of the requirements was to show two scales on the Y axis, bags / 5 minute interval, and the equivalent value in bags / hour.  I.e. bags / 5 minutes * 12.  I thought that I would be able to use a formula to specify the axis values, however, this isn’t possible in SSRS.

What I ended up with is this:

img 1

And if you’re interested, this is how I did it:

Step 1

You need to set the start and interval for the Y axis at a value that will be suitable for your data:

Right-click on the axis, select “Vertical Axis Properties”

img 1b

I set the minimum at zero and the interval at fifty

img 1c

Step 2

Calculate your corresponding Y axis values to match the interval chosen above

As mine is Value * 12 I ended up with a list like below

50 = 600, 100 = 1200, 150 = 1800, etc.

Ensure that your list goes higher than the maximum possible value buy at least one value.

Step 3

StripLines.  If you don’t know what striplines are, they are basically horizontal lines drawn across your chart at a fixed Y value (I use these for showing targets, etc).  They have a number of properties such as width, colour, title, etc.  We are going to cheat and use these to add our additional values.

To access the striplines you need to click on the Y axis and then use the Properties window, note that striplines are not accessible via Right-clicking on the axis and selecting “Vertical Axis Properties”.

If you can’t see StripLines in the properties ensure you’re in the Chart Axis properties and not the Chart (or other section).

img 2

Click on the … next to the StripLines to open the ChartStripLine Collection Editor

The properties we are interested in are:

IntervalOffset, Title and TitleVerticalAlign

We need to add one StripLine for each value in our list we made earlier

  • IntervalOffset is the value on the Y axis where you want the StripLine to appear*.
  • Title is the equivalent value.
  • And TitleVerticalAlign just stops the Title going out of line with the value

*One thing you’ll notice is that I’ve subtracted one from the IntervalOffset value, if you don’t do this the top StripLine will not be shown, so in my chart at the top the 2400 would be missing.

img 3

As we haven’t set the Colour and thickness values for the StripLine it is invisible which is why you only see the values.

Could be a little long-winded if you had a lot of values, but worked for me!

Posted in Programming | Tagged , , , | Leave a comment