Alex B. Clarke

Hi, I am a software developer specialising in Microsoft .Net technologies. This site is used to interact with, and contribute to development community.

Send mail to the author(s)  Contact me
Feed your aggregator (RSS 2.0)  Syndicate
On this page....
Categories
Archives
Blogroll
Blog Stats
Total Posts: 43
This Year: 5
This Month: 0
This Week: 0
Comments: 33
Misc
Theme by Alex B. Clarke.

Copyright © 2010 Alex B. Clarke. All rights reserved.

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

# Sunday, May 09, 2010

I came across this issue on a fairly complex page - user controls added dynamically, UpdatePanels, plenty of AJAX... etc.

It was one of the suggestions from StackOverflow that helped me solve this problem. In my case additional Page events where firing twice was due to black value for the "src" property of one of the "img" elements in resulting HTML mark-up.

Filed under: Client Side  | Published by: Alex B. Clarke  | Comments [0]
# Thursday, April 01, 2010
How to enable RDP Network Authentication Level in XP SP3
Filed under: SysAdmin  | Published by: Alex B. Clarke  | Comments [0]
# Wednesday, March 24, 2010
IIS7 and AppPool - how to set up pass-through authentication
Filed under: IIS 7  | Published by: Alex B. Clarke  | Comments [0]
# Sunday, March 21, 2010
Deals with error - "The server was unable to allocate from the system nonpaged pool because the server reached the configured limit for nonpaged pool allocations"
Filed under:   | Published by: Alex B. Clarke  | Comments [0]
A collection of web resources that I found useful when working on client side of Asp.Net applications
Filed under: Client Side  | Published by: Alex B. Clarke  | Comments [0]
# Saturday, February 28, 2009

Validate Asp.Net Page from JavaScript
Call Page_ClientValidate(), it returns TRUE if validators are happy, false if not. Use it on client side to prevent javascript code from executing if ASP.Net validators ring alarm bells.
http://www.codeproject.com/KB/aspnet/JavascriptValidation.aspx

Firefox and onChange event
First of all it is fired before keyUp or keyDown
Secondly it's fired again when cursor leaves text area

Firefox and Attributes.Add() Method
In IE to retrieve a custom attribute added in Asp.Net using Control.Attributes.Add() method, you call element.AttributeName or element['AttributeName'].
In Fire Fox we have to use
element.attributes['attributeName'].value or
element.attributes.attributeName.value

Firefox Css Class Name for Disabled Elements
You can use this class in your css file to alter the disabled elements appearance
input[disabled], textarea[disabled], option[disabled], optgroup[disabled], select[disabled]
{
  -moz-user-focus:ignore;
  -moz-user-input:disabled;
  background-color:threedface;
  color:graytext;
  cursor:inherit;
}

"This page displays secure and unsecure  content ..." Warning in IE over SSL
This can happen if, as in my case, there are relative paths to resources in client script and your site is configured to use SSL. To solve this problem either use absolute path starting with "https://" or move the paths to css. Neither FF no Safari care about it.

Cell Border Does Not Show When Cell Is Empty - IE Bug Fix
Apply the following style to the table
style="empty-cells:show; border-collapse:collapse;"

How to get Text Value from Microsoft AutoCompleteExtender
1. In the web method use the following method to create strings that will be returned in the array
AjaxControlToolkit.AutoCompleteExtender.CreateAutoCompleteItem(textToShow, valueForTheText );
2. In the AutoCompleteExtender assign event handler
OnClientItemSelected="EventHadlerClientSideMethodName"
3. In the event handler use the following method signature
EventHadlerClientSideMethodName(source, eventArgs)
4. Get text and value
eventArgs._text
eventArgs._value

IE8 will throw an error "Unterminated string constant" 
windows.setTimeOut method in IE8 will throw an error "Unterminated string constant" if newLine 
carrigeReturn is present. Hence we explicitly replace them with terminating \n\r 
IE7, FF and Opera are all fine

Example - cleaning currentTaskText
var re = /\n/g;
currentTaskText = currentTaskText.replace(re, '\\n');
re = /\r/g;
currentTaskText = currentTaskText.replace(re, '\\r');

jQuery Intellisense in Visual Studio 2008
1. Download the latest "jquery-1.3.2-vsdoc.js"
2. Place it in a folder in your project. It does not matter if the project type is "Web Site" or "Web Application"
3. Open your javascript file, the one where you want jQuery intellisense enabled, in VS2008
4. Drag "jquery-1.3.2-vsdoc.js" file and drop it in VS Editor Window. This will add a line of code similar to this one
/// <reference path="../jQuery/js/jquery-1.3.2-vsdoc.js" />

IMPORTANT
The reference must be the very first line in the file. I had a comment before it and the intellisense did not work and this kept me busy for a while, googling etc, with no results, until I just thought about it.

Just found this great post about referencing other files in javascript files in VS2008
JScript IntelliSense: A Reference for the “Reference” Tag
It covers all possibilities of referencing.  

Storing JSON Object in an Elemet's Attribute
Writing JSON object to a newly-created attribute at the time the attribute is created will not work.
So this code is not going to write JSON object correctly, instead it will write a string '[Object]'
var myJsonObj = GetMyJsonObject();
$('#' + elemetId).attr('jsonObject', myJsonObj);
Here's how you should do it
1. Create an attribute and explicitly declares its initial value as an object
$('#' + elemetId).attr('jsonObject', new Object);

2. Get JSON object you want to store and write it to the newly created attribute
var myJsonObj = GetMyJsonObject();
$('#' + elemetId).attr('jsonObject', myJsonObj);

Detecting Browsers Using CSS Style Sheet
http://www.sitepoint.com/forums/showthread.php?threadid=386094
<style type="text/css">
    head+/**/body{background:#ccffcc;}/*min-height browser but not IE7*/
    /* mac hide \*/
    * html body{background:#ccffff;}/* IE<7 */
    /* End hide */
    *+html body{background:#ffffcc;}/* IE>6 */
    </style>

also
<!--[if IE 6]>
Do IE stuff
<![endif]-->

plus
<!-- for IE7 only -->
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" href="/xtras/ie7only.css" media="screen" />
<![endif]-->
<!-- for IE6 only -->
<!--[if IE 6]>
<link rel="stylesheet" type="text/css" href="/xtras/ie6only.css" media="screen" />
<![endif]-->
<!-- for 5 & 5.5 -->
<!--[if lt IE 6]>
<link rel="stylesheet" type="text/css" href="/xtras/old.css" media="screen" />
<![endif]-->

to hide code
<!-- for everybody else except IE 5, 5.5 and 6 -->
<!--[if !IE]>-->
<link rel="stylesheet" type="text/css" href="/xtras/new.css" media="screen" />
<!--<![endif]-->


Load JavaScripts Dynamically Using jQuery.getScript()

function button_click() {
   // Check if method is defined
   if (typeof DynFunction === "undefined") {
      // Load script file where the method is defined
      var req = LoadMyScript('proj_scripts/dyn-loaded.js');
      // Check if loaded
      if (req.status === 200) {
         // Call function from the loaded file
         DynFunction();
      }
   }
}

function LoadMyScript(scriptName) {
   // Load synchronously to ensure that the file is fully loaded
   // before being used
   $.ajaxSetup({ async: false });
   var req = $.getScript(scriptName);
   // Revert back to async loading
   $.ajaxSetup({ async: true });
   alert('status: ' + req.status + '\n\rstatusText: ' + req.statusText);
   return req;
}

 

Reference jQuery in Master Page

 <%--Referencing javascript in a master page maintaining intllisence--%>
 <%--Notice '~' sign in the script reference--%>
 <%if ( false ) { %>
    <script src="~/jQuery/js/jquery-1.3.2.min.js" type="text/javascript"></script>
 <%} %>
 <script src=<%= ResolveUrl("~/jQuery/js/jquery-1.3.2.min.js") %>  type="text/javascript"></script>
 <%--End--%>
Filed under: Client Side  | Published by: Alex B. Clarke  | Comments [0]
# Thursday, January 01, 2009

Scott Guthrie put together a very extensive list of Asp.Net resources:
http://weblogs.asp.net/scottgu/archive/2006/02/24/438953.aspx

A step by step to how to move membership tables from MS SQL express Edition to your database that you are used on your web site. The second part we will go in details to configure our asp.net web site
http://www.c-sharpcorner.com/uploadfile/dsdaf/104012006083052am/1.aspx

Access Database Provider
http://blog.krisvandermast.com/UsingAccessInsteadOfSQLServerForYourASPNETApplicationServices.aspx

Filed under: Asp.Net  | Published by: Alex B. Clarke  | Comments [0]

A list of short videos on various aspects of dev work and technologies

http://msdn.microsoft.com/en-us/bb629407.aspx

Filed under: Learn  | Published by: Alex B. Clarke  | Comments [0]
# Thursday, November 27, 2008

How to install link

Thanks to Windows Coding

Filed under: Main  | Published by: Alex B. Clarke  | Comments [0]
# Wednesday, September 03, 2008

Today I've been working on implementing "drag-and-drop" functionality between two ListView controls. There is a good sample on Microsoft Help and Support web site "The ListView control does not support drag-and-drop functionality for items at run time" that I used as a starting point.

I have a basic model working just fine except for one thing. When ListViewItems are to be moved (rather than copied), they should be removed from the "source" ListView, however, the DragDrop event handler of the "destination"  ListViewControl does not contain any reference to the "source".

Tomorrow, I shall try to find a good solution for this problem.

It's all done now and in production ;) When my current contract ends I will have more time to describe the solution.

Filed under: WinForms  | Published by: Alex B. Clarke  | Comments [0]