Thursday, January 29, 2009

Windows Server 2008 can't end process

Open PDF...

AcroRd32.exe is "(Not Responding)".

Click close and "End Process"...

AcroRd32.exe is "(Not Responding)".

Task Manager
"AcroRd32.exe *32" (PID 6260). End Process...

AcroRd32.exe is "(Not Responding)".

Task Manager
"AcroRd32.exe *32" (PID 6260). Right click. End Process Tree...

AcroRd32.exe is "(Not Responding)".

Administrator: Command Prompt.
> taskkill /PID 6260
SUCCESS: The process with PID 6260 has been terminated.

AcroRd32.exe is "(Not Responding)".

Administrator: Command Prompt.
> taskkill /F /PID 6260
SUCCESS: The process with PID 6260 has been terminated.

AcroRd32.exe is "(Not Responding)".

Administrator: Command Prompt.
> taskkill /F /IM AcroRd32.exe /T
SUCCESS: The process with PID 6260 (child process of PID 3748) has been terminat ed.

AcroRd32.exe is "(Not Responding)".

Hold down the power butto...

Click "I Agree" at Task Manager CANNOT KILL PROCESSES in Windows Vista General Discussion

Wednesday, January 28, 2009

IIS 7.0 Wildcard script map for classic pipeline mode

I needed a way to pass off requests from IIS 7 (classic pipeline) to ASP.NET so that a custom HttpHandler could redirect to a new page. The article Wildcard script mapping and IIS 7 integrated pipeline has a section Wildcard script mapping in IIS 7 classic pipeline mode that provides step by step instructions.

Monday, January 26, 2009

SOQL Injection

When user input is used to dynamically build the Condition Expression in SOQL queries be sure to escape single quotes and back slashes (I.e. Reserved Characters) to avoid SOQL Injection.

This is mainly applicable to building literal strings. For other data types the presence of these characters indicates an error.

System.Web.HttpServerUtility.UrlEncode outside ASP.NET

The constructor for HttpServerUtility is internal so it can't be used outside of an ASP.NET application. Use System.Web.HttpUtility.UrlEncode instead.

Friday, January 23, 2009

ASP.NET 2.0 Multiline TextBox submits on enter in Firefox

I'm sure I've run into this issue before. If a form contains a asp:TextBox with TextMode="MultiLine" and you press enter in the textbox to create a new line the entire form gets submitted to the server in Firefox.

In my case Firebug revealed that the textarea was nested in a asp:Panel where onkeypress="javascript:return WebForm_FireDefaultButton(event, 'ctl03_ctl05_btnSubmit')"

A little Googling on FireDefaultButton reminded me that its implementation is IE specific. The following article shows how to register a client script include that will update the function.

Multi-line Text boxes and the DefaultButton in ASP.NET 2.0

The same issue is also discussed on StackOverflow: Asp.Net Form DefaultButton Error in Firefox and StackOverflow: enter key to insert newline in asp.net multiline textbox control

function WebForm_FireDefaultButton(event, target) {
 if (event.keyCode == 13) {
 var src = event.srcElement || event.target;
 if (!src || (src.tagName.toLowerCase() != "textarea")) {
 var defaultButton;
 if (__nonMSDOMBrowser) {
 defaultButton = document.getElementById(target);
 }
 else {
 defaultButton = document.all[target];
 }
 if (defaultButton && typeof(defaultButton.click) != "undefined") {
 defaultButton.click();
 event.cancelBubble = true;
 if (event.stopPropagation) event.stopPropagation();
 return false;
 }
 }
 }
 return true;
}

Sitecore Australia User Group

The Sitecore Australia user group (SCAUG) is to become a center for sharing knowledge and practical experience for Australian and New Zealand Sitecore developers and enthusiasts.

Tuesday, January 20, 2009

Converting Salesforce API DateTime from UTC to the users timezone using TimeZoneSidKey

With .NET 3.5 the System.TimeZoneInfo class can be used to convert the UTC DateTime to the users time zone, including changes required for daylight savings. The basic steps involve:
  GetUserInfoResult userInfo = binding.getUserInfo();
  string userTimeZoneSidKey = userInfo.userTimeZone;

  string timeZoneKey = string.Empty;
  switch (userTimeZoneSidKey)
  {
    case "America/Los_Angeles":
      timeZoneKey = "Pacific Standard Time";
      break;
    case "Pacific/Auckland":
      timeZoneKey = "New Zealand Standard Time";
      break;
    //...
  }

  TimeZoneInfo timeZone = TimeZoneInfo.FindSystemTimeZoneById(timeZoneKey);
  DateTime timeZoneDateTime = TimeZoneInfo.ConvertTimeFromUtc(utcDateTime, 
     timeZone);
The pain point here is the huge switch statement required to map the Salesforce TimeZoneSidKey to a valid TimeZoneInfo Id. See also:

Sitecore 6 C# snippets including item URL

Sitecore.Context

Sitecore.Context.Item the requested URL's target item.

Get the URL for an item

string urlOfItem = Sitecore.Links.LinkManager.GetItemUrl(item);

string currentItemUrl = Sitecore.Links.LinkManager.GetItemUrl(Sitecore.Context.Item);

Get the full URL for an item

Sitecore.Links.UrlOptions urlOptions = Sitecore.Links.LinkManager.GetDefaultUrlOptions(); 
urlOptions.AlwaysIncludeServerUrl = false;
string currentItemUrl = Sitecore.Links.LinkManager.GetItemUrl(sample,urlOptions);

Get an items field value

string fieldValue = item["fieldname"];
FieldRenderer.Render(item, "fieldname");

Children

Sitecore.Collections.ChildList children = item.GetChildren(ChildListOptions.None);