SQL Server Dynamic Query SQL Server without using Dynamic SQL but with XML

There always seems to be  a need for dynamic SQL, but security seems too limit where it can be used.  I found the article and it seemed very intriguing, but have not been able to deeply look into it, so I’m going to put it here for future reading.
 
"Running a Dynamic Query against SQL Server without using Dynamic SQL"

JavaScript IE FireFox onload

There are problems with FireFox using onload.  Most of the documentation and articles that I have read identifies that FireFox does not support onload.  I currently have FireFox 3 installed and onload seems to work.  But I have not been able to test onload on previous versions of FireFox.
 
I’m probably going to have to implement a solution for previous version of FireFox.  I have found some good reference of doing onload with previous version of FF, but do not have time to implement it right now.  I’m just going to put the references here so I can find them later.
 
 
BWCJP posted the following code at http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2811631&SiteID=1
I believe the latest version of fire fox and likely the previous version require ‘document’ and not window as thats for IE and Opera accepts window also
//set page event handlers
if (window.attachEvent) {
  //IE and Opera
  window.attachEvent("onload", Page_Load);
  window.attachEvent("onunload", Page_Unload);
} else {
  //FireFox
  document.addEventListener("DOMContentLoaded", Page_Load, false);
  document.addEventListener("unload", Page_Unload, false);
}
 
Reference
Firefox IE7 onload event question
 
The window.onload Problem – Solved!

Passing Dictionary From JavaScript to ASP.NET Web Service

The ASP.NET project that I’m currently working on uses AJAX to save data to a Web Service.  The web service is generic.  The web page should be able to pass address, phone numbers, sales info and etc to the web service.  Base on the key that is also passed to the web service, the web service should know how to save the data.
 
The first version of the client code that called the web service gathered all the data from the form and created a string that was pipe delimited.  Example: key=person|keyid=333323|firstname=John|lastname=Handcock.   When this information arrives at the web service it must be parsed and saved. A lot of red flags seem to pop up with this design.
 
Here’s the web service signature or the first version
[ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet=false)]
public string Save(string input)
 
There will always be a few fields that will be passed (key and keyID) to the web service.  The problem is that data fields (firstname, lastname, address and etc) could be different.  I figured out that I could add .NET Dictionary type to as a parameter to web service call.  The problem now is how do I gather and pass this information from the client javascript.
 
Here’s the the new save method web service
[ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet=false)]
public string Save(string key, string keyID, Dictionary<string, string> inputNameValue)
 
I could use the following JavaScript to pass data to the web service and it works, but the data values (first, last) need to be created dynamically. 
MoFormSave.Save(key, keyID, {"first":"john","last":"handcock"})
 
I tried to create an array that accepts an NameValue object and pass the object to web service, but this errors when I call the web service.  I finally figure out I could do the following and pass the object to the web service.
 
   var nameValue = {}; //new, empty object
   nameValue[‘first’] = ‘John’;
   nameValue[‘last’] = ‘Handcock’;
   MoFormSave.Save(key, keyID,  nameValues)
 
 
Resources:
Quick guide to somewhat advanced JavaScript – tour of some OO features
 
 

JavaScript Modal While Processing

On the current ASP.NET project that I’m working on, I’m using AJAX to save the user input to a WebMethod(WebService).  While the save is running the user needs to be prompted that their data is being save.  At this time the user should not be able to do any other action on the page until the save has completed. 
 
Below are the resource that I used to solve this problem. All the resources but the first were fairly complex.  The first resource did a very good job of  solving my problem.  I listed the other resource because they provided some additional information.
 
Resources:
Modal-style pops in Javascript and CSS (The simplest and it works; works in IE7 and FireFox 3)
http://weblogs.asp.net/jeff/archive/2006/10/25/Modal_2D00_style-pops-in-Javascript-and-CSS.aspx
 
Lightbox Gone Wild (JavaScript Libary) (Looks fairly complex)
http://particletree.com/features/lightbox-gone-wild/
 
 
Javascript Modal Dialog Tutorial (Discusses issues that browses have)
http://luke.breuer.com/tutorial/javascript-modal-dialog.aspx
 
 
Modal Dialog Box – modalDialog.js (JavaScript Library)
http://www.applicationgroup.com/tutorials/modalDialog/modalDialog.asp

Cool Tools and Tips

Every time I rebuild my computer I can never remember the tools that I installed and the custom changes i make to the environemnt.  Also I added a few links to others who have similar lists.
 
 
 
 
David Yardy.

ASP.NET Debugging Stop Unexpectedly

My environment: Visual Studio 2008 (VS.NET), Vista, IIS7, ASP.NET. 
I have a situation when I’m debugging ASP.NET and after about 90 seconds of stepping through code the debugger suddenly stops and detaches.
 
Based on info from others, it seems that the underling problem is Vista and Internet Information Server 7 (IIS7).  There are two setting in IIS7 for Application Pools that can create this problem: Ping Enabled and Ping Maximum Response Time.  The default for Ping Maximum Response Time is 90 sec.  By changing these values should resolve the problem.  The references below probably provides a better overview of the problem.
 
Reference:
 
My web application times out when debugging in IIS7

Page.ResolveUrl(“~/ClientScripts/Validation.js”) – Web Application Root Operator

I have the situation where I need to load a JavaScript dynamically.  All the JS files are in the ClientScript directory (http://www.somewebsite.com/ClientScripts/Validation.js).  The ASPX page that references the client scripts could be anywhere, multiple folders (directories) down in the site or in the application root.  I would like a simple way of referencing the the application root.  The magic to this is the ~ (Tidle). The ~ resolves to the root of the current application. 
 
The following line allows me to reference the application root
this.ClientScript.RegisterClientScriptInclude("Validation.js", Page.ResolveUrl("~/ClientScripts/Validation.js"));
 
And here is the results in the HTML file.
<script src="/ClientScripts/Validation.js" type="text/javascript"></script>

ASP.NET AJAX WebServices and ScriptServices

I’ve been working with ASP.NET AJAX for the past week and the following resources allowed me to get up to speed pretty fast.  The following two books that I list are pretty good.   Both of the them cover some different information.  I believe the Professional ASP.NET 2.0 AJAX is a little easier to read and the examples are much better. 
 
Video – How Do I: Use an ASP.NET AJAX ScriptManagerProxy?
 
Video – How Do I: ASP.NET AJAX Enable an Existing Web Service?
 
Video – How Do I: Make Client-Side Network Callbacks with ASP.NET AJAX?
 
Video – How Do I: Choose Between Methods of AJAX Page Updates?
 
MSDN Article – Using ASP.NET Session State in a Web Service
 
Book – Introducing Microsoft ASP.NET AJAX (Dino Esposito)
 
Book – Professional ASP.NET 2.0 AJAX 
 
 

AJAX and JavaScript in ASP.NET & Visual Studio 2008

I have once again started working with AJAX.  About 8 months ago I was pretty deep into ASP.NET and AJAX, but since then I’ve done little with AJAX.  I’ve been finding many good reference for AJAX and do not have a common place to keep all these reference.  So for convince I’m going to keep the references here. 
 
 
Create Control Extenders
Using Visual Studio 2008, ASP.NET 3.5, and AJAX
(I went through the example in this article and everything seemed to work fine)
 
CodeProject – ASP.NET AJAX Controls and Extenders
4.36 out of 5. 
(This article looks very promissing)
 
Building ASP.NET 3.5 AJAX Extender Controls
 
MSDN – JScript IntelliSense Overview
 
WebCast – ASP.NET AJAX Support in Visual Studio 2008
(Good video)
 
WebCast – IntelliSense for Jscript and ASP.NET AJAX (in Visual Studio 2008)
 
JScript IntelliSense: A Reference for the “Reference” Tag 
/// <reference name="MicrosoftAjax.js" />