Wednesday, September 23, 2009
How to get Javascript Intellisense in VS 2008
From: Stephen Walther
Sent: Wednesday, September 23, 2009 7:43 AM
To: Meacham, Samuel @ Tempe
Subject: RE: Javascript include problem that could easily be fixed for .NET 4.0
Hi Sam,
My favorite method of handling this issue is to use the Page.ResolveUrl method in the master page like:
<%= ResolveUrl( “~/Scripts/MyScript.js” ) %>
The ResolveUrl() method replaces the tilde ~ with the name of your application so that you can move your website without breaking the paths.
Another approach to solving this problem is to use the server ScriptManager (which also resolves the tilde ~ automatically) like this:
<asp:ScriptManager id="sm" runat="Server">
<Scripts>
<asp:ScriptReference Path="~/JScript1.js" />
</Scripts>
</asp:ScriptManager>
I agree that it is a little inconsistent that the <head runat=”server”> control resolves the tilde ~ for <link> tags but not other tags like <img> and <script>. But, you always have the option of using ResolveUrl in the <head> tag.
-- Stephen
From: Scott Guthrie
Sent: Tuesday, September 22, 2009 12:56 PM
To: Meacham, Samuel @ Tempe; Stephen Walther
Subject: RE: Javascript include problem that could easily be fixed for .NET 4.0
Stephen – any thoughts on this?
Thanks,
Scott
From: Meacham, Samuel @ Tempe
Sent: Tuesday, September 22, 2009 12:40 PM
To: Scott Guthrie
Subject: Javascript include problem that could easily be fixed for .NET 4.0
Sorry for emailing directly, but the art of feature requests and suggestions, while obviously important to both producers and consumers, has always been a dark one. I’m never sure where the appropriate forum is to make sure my idea gets read.
Master pages are great, and solved a lot of problems, like making sure the same css document gets included in every page in your whole app.
Having this in the master page:
<head runat="server">
<link rel="stylesheet" type="text/css" href="~/css/default.css" />
Renders this for a page at the app’s root:
<link rel="stylesheet" type="text/css" href="css/ErrorLoggerStyle.css" />
And this for a page in a subdirectory of the root:
<link rel="stylesheet" type="text/css" href="../css/ErrorLoggerStyle.css" />
Basically, the magic ~ solves all your problems. This doesn’t work for <script> tags, which leaves me 3 choices:
· Absolute URLs (“http://...”)
· URLs relative to the domain root (“/css/file.css”)
· URLs relative to the current directory (“css/file.css”, no leading “/”).
Obviously, each method has it’s pros and cons. With completely absolute URLs, the files will always be found (as long as they are there), but this doesn’t work well when you have multiple deployments, such as production, staging, and development, that require different versions of js files. Relative URLs fail when you have web content pages in subdirectories that use master pages in the app’s root (all of the paths break). URLs relative to the domain root (“/css/file.css”) don’t work when you don’t (or can’t) know the name of the app virtual directory, or if it changes depending on which deployment of the site you’re using (“mydomain.com/myapp” vs “mydomain.com/myapp_dev”).
Our solution here has been to put an <asp:Literal> in the <head> element, and the master page’s Page_Load() writes all the <script> tags to that literal element at runtime, with the paths properly processed. We could probably create a UserControl that did the same thing, but the end result would be the same: No js intellisense at design time.
None of the above options are particularly appealing. Do you think it’s a possibility to have VS2010/.NET 4.0 support the ~ for <script src=”~/js/file.js”>? It would solve a lot of headaches for a lot of people…
Sam Meacham
It is nice to see such prompt response from a software development team. Here are some other helpful hints.
If you are updating the documentation of your JavaScript functions you may use the Update JScript IntelliSense command (Ctrl+Shift+J) from the Edit/Intellisense menu.
Using Javascript in a User Control can be problematic since you don't know where in the file structure it may be used. The following code will enable JavaScript Intellisense at design time. The "if (false)" will ensure it is not run in the browser.
<% if (false) { %>
<script language="javascript" type="text/javascript" src="../js/util.js"></script>
<% } %>
Monday, September 07, 2009
Delete Stuck Print Job
We followed the steps here. It successfully reset our print queue
Monday, August 31, 2009
"Mommy, where do ideas come from?"
Experiencing real people in their actual environments fuels our senses of empathy and intuition that helps to guide us towards the ideas that make people happy, successful (and even better looking). Plus, the research phase affords us the opportunity to be fully immersed in the users and the domain for a few weeks at the start of the project, which in addition to providing rich data and empathy, also gives our brains boot-up time to start noodling on the problem and explore possible solutions in the background.I am particularly satisfied when a solution I have created has made someone else work easier. I makes it more real when I talked with them or interacted in some other way.
I am convinced that if we invest some time in describing in words the experience we want our users to have it will pay dividends.Sometimes, words are worth 1,000 pictures
The first step in our design ideation process comes before any “official” sketching is done: we describe the users’ ideal experience in words. The scenarios we develop at this stage are forward-looking and technology-agnostic, focusing on the personas and how they think, feel and behave rather than on specific interface elements or technical implementations.
There’s something special about the process of sketching - even jotting down some really bad ideas helps us learn about the tensions on the problem and gets us closer to a workable solution.I love having the large jotting paper available to us since our move to our new office.
The power of paired designing
Because we work in pairs, Cooper designers often can’t say for sure where one person’s idea ends and the other’s begins. But what we do know is that our design partners are a major source of inspiration and design ideas. We come up with ideas while we’re talking through the problem with our partners, or while listening to them talk through it with us. We piggyback on each others’ ideas, zeroing in on what’s good about our partner’s proposed solution and tweaking what’s not working, buoyed by the collective energy in the room. And just having someone there to call b.s. when we’ve gone too far off the reservation frees us up to explore novel and even downright crazy solutions that may yield useful insights or contain aspects that can be applied to a more practical design approach.
As Richard Buchanan (Emma’s grad school professor) used to say, “Ideas don’t live in your brain or my brain but in the collective space between our brains.”
I know that one of the successes of MOS was the paired designing Sam and I did.
Don’t be afraid to stare out the window
One of the benefits our designers enjoy is that we are typically assigned to only one project at a time, which means that our design problems not only get our focused attention during work hours, but also find their way into our background brain cycles outside of the office. Oftentimes, ideas come in the shower, on a run or bike ride, or while washing dishes - any time that our minds are given the freedom to wander. Even here in the studio, you’ll often see designers staring out the window, watching a ship come into port or commuter-ants scurry through the crowded streets below. Taking some quiet time for woolgathering helps to reduce stress, while also distracting the judging part of our brains. After letting our minds meander for a bit, we can often corral some of those fragmented thoughts into a useful idea.
I am amazed at the amount of inspiration and motivation I get when I am mowing the lawn, working in my garden or just walking. Maybe there is something to the physical movement. Something about a simple task that doesn't take my brain power.
Wednesday, August 26, 2009
Modify Your Command Prompt Settings
Open your command prompt. Right click on the title bar and choose properties.
- Under the Options tab in the Edit Options section I checked QuickEdit Mode. This allows you to select text and hit enter to copy text to the clipboard.
- Under the Layout tab, I changed the Screen buffer width to 100 and the height to 500. I changed the Window width to 100 and the height to 35
When you click OK, you tell it to "save properties for future windows with the same title". If you open your command prompt from a short cut you choose "Modify shortcut that started this window".
Thursday, August 20, 2009
Wednesday, July 22, 2009
UDF to summarize data by the week
/*BEGIN Proof of concept script of a user defined function
This script will clean up after itself
Written by Rich Alger 2009-07-22
*/
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[MyTable]') AND type in (N'U'))
DROP TABLE [dbo].[MyTable]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[MyTable]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[MyTable](
[Id] [int] IDENTITY(1,1) NOT NULL,
[DateCreated] [datetime] NOT NULL,
CONSTRAINT [PK_MyTable] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[udf_WeekOf]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
DROP FUNCTION [dbo].[udf_WeekOf]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[udf_WeekOf]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
BEGIN
execute dbo.sp_executesql @statement = N'CREATE FUNCTION [dbo].[udf_WeekOf](@InDate DATETIME)
RETURNS DATETIME
AS
/* Return the 12:00 am of Sunday before the date passed in */
BEGIN
DECLARE @DatePartOfInDate DATETIME
SET @DatePartOfInDate = CAST(CONVERT(VARCHAR(10), @InDate, 120) AS DATETIME)
DECLARE @WeekdayOfInDate INT
SET @WeekdayOfInDate = DATEPART(weekday, @InDate)
RETURN DATEADD(DAY, (-1 * (@WeekdayOfInDate-1) ), @DatePartOfInDate)
END
'
END
GO
INSERT INTO MyTable (DateCreated) VALUES ('2008-12-30 08:32:27')
INSERT INTO MyTable (DateCreated) VALUES ('2009-01-02 12:17:16')
INSERT INTO MyTable (DateCreated) VALUES ('2009-01-06 09:02:43')
INSERT INTO MyTable (DateCreated) VALUES ('2009-01-13 16:53:02')
INSERT INTO MyTable (DateCreated) VALUES ('2009-01-14 11:12:34')
INSERT INTO MyTable (DateCreated) VALUES ('2009-01-15 13:38:23')
SELECT
Id
,DateCreated
, dbo.udf_WeekOf(DateCreated) AS WeekOf
FROM MyTable
SELECT
COUNT(*) AS RecordInWeekOf
, dbo.udf_WeekOf(DateCreated) AS WeekOf
FROM MyTable
GROUP BY dbo.udf_WeekOf(DateCreated)
GO
/* This will drop the objects*/
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[udf_WeekOf]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
DROP FUNCTION [dbo].[udf_WeekOf]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[MyTable]') AND type in (N'U'))
DROP TABLE [dbo].[MyTable]
GO
/*END Proof of concept */
The following script will only add the user defined function
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[udf_WeekOf]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
DROP FUNCTION [dbo].[udf_WeekOf]
GO
CREATE FUNCTION [dbo].[udf_WeekOf](@InDate DATETIME)
RETURNS DATETIME
AS
/* Return the 12:00 am of Sunday before the date passed in */
BEGIN
DECLARE @DatePartOfInDate DATETIME
SET @DatePartOfInDate = CAST(CONVERT(VARCHAR(10), @InDate, 120) AS DATETIME)
DECLARE @WeekdayOfInDate INT
SET @WeekdayOfInDate = DATEPART(weekday, @InDate)
RETURN DATEADD(DAY, (-1 * (@WeekdayOfInDate-1) ), @DatePartOfInDate)
END
Thursday, June 11, 2009
Enabling Concurrent Remote Desktop Sessions on Windows XP SP3
If you have multiple users on your Windows XP machine, you might have heard it is possible to patch the terminal services service, to support multiple concurrent remote desktop connection (via RDP) to your computer.
...
