Monday, November 27, 2006

MOSS 2007 and WSS3 Functional Architecture Diagram

Here is the colourful and comprehennsive diagram illustrating the functional architecture of the most latest of Microsoft Office Sharepoint Server 2007 and Windows Sharepoint Services 3.0.

Saturday, November 25, 2006

Release of WSS RTW and MOSS Standard and Enterprise Edition

YOu can download the Release-To-Web version of WSS (Windows SharePoint Services) and Microsoft Office SharePoint Server 2007 Evaluation version at

1. Microsoft Office SharePoint Server 2007 x86 English Evaluation
2. Windows SharePoint Services 3.0

CD Keys available for standard and enterprise edition are

SharePoint Server Standard Trial: XJMKW-8T7PR-76XT6-RTC8G-VVWCQ
SharePoint Server Enterprise Trial: F2JBW-4PDJC-HKXTJ-YCKRP-T2J9D

For more resources about installation, upgrade, versioning, check this link, from Microsoft SharePoint Products and Technologies Team Blog

Thursday, November 23, 2006

Efficient String Concatenation in JS

In .NET, we use StringBuilder if we need to concatenate strings for better string manipulation performance. For instance,

StringBuilder builder = new StringBuilder();
builder.append("This");
builder.append("is");
builder.append("really");
builder.append("good");
builder.append("for");
builder.append("performance");

string str = builder.ToString();

In JS, we can also do the same thing for better memory allocation in string concatenation too.

var builder = new Array();
builder.push("This");
builder.push("is");
builder.push("really");
builder.push("good");
builder.push("for");
builder.push("performance");

var str = builder.join("");


This method will perform faster if the number of string concatenation is huge. THe normal += operator will win, otherwise.

Check Efficient JavaScript for more information on optimizing JS code

Tuesday, November 21, 2006

Invoking Executeable File from ASP.NET Web Services

Below is the code snippet on how to invoke the executable file (exe) from the cmd.exew being executed.

// Execute the Command Prompt
ProcessStartInfo psi = new ProcessStartInfo("cmd.exe");

// Indicating the input read from the process's standard input
psi.RedirectStandardInput = true;
psi.UseShellExecute = false;

// Do not show the GUI of the running app
psi.CreateNoWindow = true;

Process process = null;
try
{
// Execute the cmd.exe
process = Process.Start(psi);

StreamWriter writer = process.StandardInput;

// Write the command to the command prompt
writer.WriteLine("notepad");

}
catch (Exception ex)
{
// do something here
}
finally
{
if (process != null)
{
process.Close();
}
}


The code will simply run the notepad from the cmd.exe. You can just call "notepad" from at line the of ProcessStartInfo psi = new ProcessStartInfo("notepad");, but I am showing how are you going to write the command to the cmd using the StandardInput of Process object.

Similarly, you can call batch file from the cmd to execute command in the batch file too, or store those static command in the resource files (resx) inside the app_GlobalResources folder and get from the key by

Resources.<Resource file name>.<key name>

MSDN Magazine - HTML Help Downloads

If you want to read MSDN Magazine contents wherever you are, you can download the dozens of MSDN Magazine in portable chm format at http://msdn.microsoft.com/msdnmag/htmlhelp.aspx

Use of ResolveClientUrl() method in getting browser-acceptable relative URL

In .NET, we always use tilde (~) to refer to root virtual directory of the web application. For instance,

<asp:Image runat="server" ImageUrl="~/images/mypic.gif" />

However, in order to generate a URL that can be used by client-side browser, the URL is actually resolved in the AddAttributesToRender() of the Image server control.

writer.AddAttribute(HtmlTextWriterAttribute.Src, ResolveUrl(ImageUrl));

That is the reason why you can use "~" in the ImageUrl property. But I afraid this might be the case if you do the same thing upon the normal HTML elements or HtmlGenericControl, such as :

<img src="~/images/mypic.gif" alt="" />

because the browser does not recognise what the "~" symbol stands for. In order to workaround with that, this is where the ResolveClientUrl() method comes into place.

<img src='<%= ResolveClientUrl("~/images/mypic.gif") %>' />

Apart from using it in HTML, it can also be used in code-behind that involves in getting the relative path for the URL. For instance, ResolveClientUrl() method is handy when we are trying to register the javascript reference in code-behind,

this.Page.ClientScript.RegisterClientScriptInclude(this.GetType(),"MyScript", this.ResolveClientUrl("~/images/myscript.js"));

Not only that, you will always need this method in your custom server control development.

Thursday, November 02, 2006

Debugging JS in VS 2005 using Script Explorer

Breakpoint is one of the useful features available in Visual Studio 2003/2005 to allow developers to trace the current value of variable at the location where the debugger is currently running at. Nevertheless, you can set any breakpoint in the code-behind of the aspx page, but not in declaractive page. No particular client-side javascript function codes can simply be set as breakpoint in Visual Studio.

I rarely debug the client-side JS codes, or I can say NEVER! I have tried to debug it using Script Explorer today and it impressed me. To debug the client-side JavaScript functions, you can use the only-visible-in-debugging-environment Script Explorer in Visual Studio 2003/2005. There are few steps need to be followed:

1. Enable Client-side Script Debugging

IE -> Tools Menu -> Options Menu -> Advanced Tab -> Untick " Disable script debugging check box" in Browsing category.



2. In VS environment, write a simple JS function in external functions.js

function MyLoad(name)
{
var message = "Welcome, " + name;
alert(message);
}

Then, invoke the function in body's load() event in ASPX page.

window.onload = MyLoad("Alvin");

3. Press F5 to debug the page. In debug mode, go to Debug Menu->Windows-> Script Explorer (this option only appears in debug mode). The window of Script Explorer will be shown.



4. Once you debugging the page, you will see list of JS files/resources shown in Script Explorer in tree view.



Double click the "functions.js" and set the breakpoint at particular line. The debugger will stop at that line when it passing through it.




Additionals
If your javascript functions are in the aspx page, you can add breakpoint by

Debug Menu -> "Add Breakpoint" -> "Break At Function" -> type your method name there and choose right language.




Read more in MSDN
1. How to: Debug a Client-Side Script from Microsoft Internet Explorer
2. How to: Enable Client-Side Script Debugging
3. How to: Set a Function Breakpoint


I need a break....