Using Web Essentials 2015 Color Palette

Wednesday, October 7, 2015 0 comments

One of the most popular Visual Studio extensions is Web Essentials. One of my favorite features is the extra stylesheet support WE gives Visual Studio. Making sure that the numbers of colors in a web site doesn't get out of control can be a big deal. Having a consistent color palette makes a real difference in the overall feel of a web application.

After you install the extension you should see a new menu in the toolbar called Web Essentials. It will look like this.

If you click "Create color palette" you'll add a css file to the Solution Items. This file is named specifically "WE-Palette.css". Do not rename it or move it. If you happen to remove it, but do not delete it then you'll be stuck. The file might still be in the solution folder but hidden from the project. You will have to delete it or Visual Studio won't be able to create it. You'll be stuck in a state of color palette limbo.

In this example I created a solution settings file and a color palette already. The extension sees the existing files and does not let you write over them.

So what does a color palette file look like?

It's nothing to complicated. It's just a list of colors. The trick is that the order matters. When you now type "#" in a CSS or LESS file, Visual Studio's IntelliSense feature gives you a wonderful picker that shows your color palette.

Hit #

It is that easy. It's also easy to extend. So lets add an orange color to the WE-Palette.css file and save the file.

It kind of fits our color scheme. I like it. Let's go add it in our style.css file by hitting #.

Yep. This Web Essentials (WE) Visual Studio extension is pretty darn cool. More stylesheet features can be found at:

SQL Code Guard Review

Thursday, October 1, 2015 0 comments

Pro Tip: Don't Trust Yourself

I had not used this product for a while but recently installed it again.  When I'm focused on frontend work and other developers are handling the backend, I don't write any SQL.  It's nice to work on teams that have brilliant database developers that you can count on to use best practices.
I'm currently back to being a full stack developer on a project and the database is not my own.  I don't want to make mistakes that might slow up the team.  So I need all the help I can get.  I'm not saying that I'm a bad developer.  In fact, I get a lot of props from other developers on my SQL skills.  But I'm not perfect.
SQL Code Guard is a free add-in for SQL Server Management Studio and Visual Studio.  Sorry, there isn't a VS 2015 build yet that I can find.  That could change by the time you read this.  I use it with SSMS the most. ( You should also install Red Gates SQL Search.  I like it also. )


What does SQL Code Guard do?

The add-in does four different things:
  • Code issues  - my favorite feature
  • Object dependencies - helps solve that oops when Visual Studio missed it
  • Code complexity - Bad SQL is not job security.  It's what should get you fired.
  • Code outline - great for understanding complex stored procedures 


"I have Visual Studio, I don't need anything more."

Visual Studio database projects use msbuild when you build them.  Building your database, parsing it and making sure certain dependencies are checked, is wonderful.  It's probably not enough.  Just take one of your databases that builds fine in VS and use the Code Issues tool in SQL Code Guard once.  I bet it will find something you forgot.  Maybe there is a SELECT *, or a missing ELSE?
You can also add SQL Code Guard to your build.  It even has a Check-in Policy so databases don't get into Team Foundation Server without at least a minimum standard to quality.

My Humble Opinion

The tool is free and is light weight.  I don't see any reason why you shouldn't try it out or give it to other developers.  You might be good enough that the supported issues are just second nature, but maybe a free tool could help.  If it does, then the developers like me who have to work in your database later will thank you for using something.
Whatever you do, please don't leave BP017 out there in your databases.  It's a killer.  See what I did there?  I just dropped a teaser.  Now you have to go and find out what BP017 is. :-)

Resolve associated work items on check in.. Finally!

Wednesday, September 16, 2015 0 comments
In Visual Studio 2015, Microsoft has fixed that default setting everyone hates.  Well, I bet the majority of developers hate it.  No? Just keep reading anyway.

By default, when you relate a work item to a check in, if the work item is not resolved or closed, it tries to resolve the work item for you.  Why?  I don't know. It's always been that way.

This, for me, is a real pain.  I don't, by default, want to do that.  I (usually) want to associate the work item.  So how do I change the default?  Prior to VS 2015 you had to edit your registry and restart Visual Studio.  Doesn't that sound like a great user experience?

Here is how to do that if you have not upgraded or need to use another version other than 2015:  I think it still works.  I only have Visual Studio 2015 now so I don't care.

Thanks to user input the team at Microsoft has created a new setting. It only received 845 votes.  It should have received a lot more.

The setting is under Tools > Options > Source Control > Visual Studio Team Foundation Server.

This isn't worded the best but that is the setting we have been asking for.  If you un-check the box, from then on the default will be associate for open work items.  You don't have to restart or anything but you will need to re-add your work item to see the affect.

Happy programming!

Data-driven subscriptions cannot be created

Tuesday, August 18, 2015 0 comments
So you get this wonderful error from SQL Server Reporting Services when you try to add a data driven subscription to your report:

Data-driven subscriptions cannot be created because the credentials used to run the report are not stored, the report is using user-defined parameter values, or if a linked report, the link is no longer valid.
You look and you are using a shared data source that has saved credentials.  So that's not it.

You check and the report is not linked to any other report.  So that's not it.

You go ahead and remove all the parameters and publish.  So that's not it.

Is SSRS a liar?  Dumb Microsoft goofed again right.  Not so fast.  This is still something you can fix.  I came across something that could help.  Check on the Variables section.

In the rdl file's xml there is a <Variables></Variables> section.  Remove it and publish.  The error will go away.  You can also see it in the Report Properties.

You'll see a variable there that needs to be deleted, if this solution is a solution to your problem.

Good luck and I hope this helped.


Thursday, July 9, 2015 0 comments
This one is new for me. It might be something you have to consider all the time. I do not.

Stored procedures in SQL may have defaults for certain options set only at creation. So you can't override them or even alter them. You have to drop and recreate them if those options have an affect on your query.

This probably doesn't affect 99% of your queries. It doesn't affect mine too much. Today I had to so a bit of XML in my stored procedure though. It worked in dev fine because of course my options are set differently than in another server. When I gave the script to someone else to try... whammo!
SELECT failed because the following SET options have incorrect settings: 'QUOTED_IDENTIFIER'

What the hell does that mean? Is this Office Space? PC LOAD LETTER!

No it's not a movie. This is real life and SQL has this cool table called sys.sql_modules. It can store options that you have set when you created that bloody stored procedure that isn't working now.

SELECT name = OBJECT_NAME([object_id]), uses_quoted_identifier
FROM sys.sql_modules
WHERE OBJECT_NAME([object_id]) IN (N'sproc1', N'spoc2');

In this example our stored procedure is called sproc1. The columns we can look for are:
  • object_id
  • definition
  • uses_ansi_nulls
  • uses_quoted_identifier
  • is_schema_bound
  • uses_database_collation
  • is_recompiled
  • null_on_null_input
  • execute_as_principal_id

For this example our results prove that we do have a problem.

name uses_quoted_identifier
---- ---------------
sproc1 0
sproc2 1

So how do we fix this. We can't do an alter. We have to recreate the stored procedure. Yep, what a pain in the butt.  It's because of the darn XML and STUFF() that we are doing to put some rows all together into a delimited string.  Please don't focus on that.. it's the QUOTED_IDENTIFIER ON that is the bug.

--drop the sp and recreate with the correct set options.

IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[
sproc1]') AND type in (N'P', N'PC'))



-- important


-- important for xml queries



-- important for mapping in Entity Framework

-- SELECT an existing row from the table.

[Id] INT,
[Description] VARCHAR (200),

Things(Id, Description, Date)
SELECT ID, Description, Date
TableB ON TableB.ID = TableA.ID

SELECT ', ' + b.Description
TableA b
WHERE (b.Id = a.Id)
FOR XML PATH(''),TYPE).value('(./text())[1]','VARCHAR(MAX)')
,1,2,'') AS
Things a




Recruiters should not call or email me.

Wednesday, February 25, 2015 0 comments
I have changed positions over the years. It does happen. I do answer my phone and read my email. I like talking to other developers and entrepreneurs about technology. Sometimes that might involve me coding for them or with them.

I don't like it when a recruiter calls me up looking to place someone they know or wanting to fill a role they have. Please don't bother me. I won't be nice to you when you call and I'll block your email.

You can contact me on LinkedIn if you want. That is what LinkedIn is for. Calling me up at all hours of the day and night isn't going to help you, at all.

The ActionName attribute is very powerful in Sitefinity

Friday, October 3, 2014 0 comments
If you haven’t heard, Sitefinity allows for not only ASP.NET WebForms development but also ASP.NET MVC development. There are different modes to MVC development in Sitefinity: Classic, Pure, and Hybrid.  I think the most common would be hybrid.  If you have an existing site and add a new MVC widget, you’re probably going to use Hybrid.

Code in Hybrid mode is a mix of WebForms in your MasterPages and Razor ASP.NET MVC in your widgets.  The routes in Hybrid mode are mixed also.  I mean to say that the routes are built for WebForms to work first and MVC second. Because of this you need to pay attention to the ActionName attribute on your control ActionResults and also your form tags.
Your controller
   1: /// <summary>
   2: /// This is the success Action.
   3: /// </summary>
   4: [ActionName("Success")]
   5: public ActionResult Success()
   6: {
   7: LoginModel model = new LoginModel();
   8: return View(model);
   9: }
  11: [HttpPost]
  12: [ActionName("Success")]
  13: public ActionResult Success(LoginModel model)
  14: {
  15: if(ModelState.IsValid)
  16: {
  18: }
  19: return View(model);
  20: }

Note that we use the ActionName attribute “Success”.  Normally you don’t have to do this.  The ActionName is inferred from the method name.  In Sitefinity Hybrid mode this is not the case.

Your view
   1: @model SitefinityWebApp.Mvc.Models.LoginModel
   2: <h1>
   3: @ViewData["HeaderText"]
   4: </h1>
   5: @using (Html.BeginFormSitefinity("Success", "<NAME OF WIDGET>", FormMethod.Post))
   6: {
   8: }

In your MVC view, you’ll use the helper BeginFormSitefinity.  A good convention is to use the name of the widget as the form name and we need to use the ActionName attribute “Success” in this sample to match our controller.  Here we are posting a form with inputs.

I hope this explains the power of ActionName.  It is seldom used it normal MVC development but necessary to Sitefinity MVC development.
Copyright © Aaron Stanley King