Sunday, December 25, 2005

C# 2.0 : Property Access Modifier

In C# 2.0, you can specified different access for your property getter and setter.

In the folloing example, your can specify the getter for your Name property to have public access, but your setter is protected, which is only accessible from derived class.


public string Name
{
get
{
return name;
}
protected set
{
name = value;
}
}

Labels:

Friday, December 23, 2005

C# 2.0 : ?? Operator

C# 2.0 introduce a new operator "??". Make no mistake, it is a double question mark.

This operator evaluate an expression and return the value of the expression if not null, else return a default value.

a ?? "default" is equivalent to :


if(a == null)
return "default";
else
return a;


Try the following example:

static void Main(string[] args)
{
string aa = "abcd";

// This will print "abcd".
Console.WriteLine("aa is {0}", aa ?? "default text");

aa = null;
// This will print "default text".
Console.WriteLine("aa is {0}", aa ?? "default text");
}


Coming up next : Visual Studio 2005 Debugger Visualizer.

Labels:

Tuesday, December 06, 2005

My 2005 reading list

Hitting my target again of reading 5 books a year. My reading list this year is:

How Would You Move Mount Fuji
.NET Application Architecture
The Art of Deception
Professional Software Development
The Art of Long View.
Show Stopper.
The Design of Everyday Thing.


Currently reading : The Search.

WSS : Display document library in another WSS site (Caveat)

You can insert a Page Viewer Web Part into a WSS site that show the document library of another site by specifying the following URL for the Page Viewer Web Part:

http://[Server]/[Site Path]/_vti_bin/owssvr.dll?dialogview=FileOpen&location=DocLibName

Follow the link below to read about it.
How to display a single document library in another WSS site?

However, this does not work if your WSS site is created using the "Project Workspace" site definition. "Project Workspace"is a site definition which is added by Project Server 2003 when you install Project Server 2003.

You will notice the Page Viewer Web Part will flash the document library for a while and then it will turn to a blank page. If you View Source on the Web Part, the content is actually still there.

After some digging around, I found out it is cause by the JavaScript inserted by the "Project Workspace" definition.

If you look into Template\LAYOUTS\1033\PWAINC\CUSTOM.JS, it register the GlobalInit() function to be called on page load. Going into the function you will see the following code:


function GlobalInit()
{
try
{
if(window.parent != window)
{
bHostedinPWA = true;
}
}
catch(e)
{
bHostedinPWA = true;
}


Basically what it does is it check whether the page is loaded in the top level browser window. If not(EG: You load it inside a IFRAME), it will hide the contents(you can learn about this if you trace deeper into the code).

One workaround is to remove that checking in custom.js.

Labels: