Tuesday, March 30, 2010

Sharepoint 2 - Cascaded Lookup Dropdowns

there is a javascript components we can use directly, follow the instruction of this link,http://www.sharepointboris.net/js/spcd/

1. Download the spcd.js from codeplex: http://spcd.codeplex.com/

2. Upload our spcd.js to our documents library

3. Build the list show the relationship with the dropdown item and child nodes, such as: product-newspapers list, product-version list.

4. In the item page, add 2 paramters to the URL: PageView=Shared&ToolPaneView=2 and add the Content Editor Webparts

5. Specify the javascript code in the source code editor, like:
< script type="text/javascript" src="[paste-javascript-url-here]">
var ccd1 = new cascadeDropdowns(ParentDropDownTitle, ChildDropDownTitle, Child2ParentFieldIntName, ChildListNameOrGuid, ChildLookupTargetField);
< /script>

For example:
< script type="text/javascript">
var ccd1 = new cascadeDropdowns("Account", "Branch", "Account", "Branches", "Title");
< /script>

Sharepoint 1-The Way to find the GUID of a List

•Copy the Url from the browser address bar into Notepad. It will look something like:
http://moss2007/ProjectX/_layouts/listedit.aspx?List=%7B26534EF9%2DAB3A%2D46E0%2DAE56%2DEFF168BE562F%7D


for the list url:



Delete everying before and including “List=”.
Change “%7B” to “{”
Change all “%2D” to “-“
Chnage “%7D” to “}”

Monday, March 15, 2010

Convert String to integer

int i = Convert.ToInt32(str);

int i = int.Parse(str);

int i;
int.TryParse(str, out i);

But for the third method, i cannot be property. It will come out an error:
A property or indexer may not be passed as an out or ref parameter.

Monday, March 1, 2010

Ref and out parameters

ref= in and out. Both allow the member functions to change the values of the parameters. So the difference between ref and out is ,for out, the variable passed as the parameter doesn’t have to have a known value before the call.

Here are an example:

static void Main()
{
string value1 = "cat";
SetString1(ref value1);
Console.WriteLine(value1);

string value2; // Unassigned string
SetString2(out value2);
Console.WriteLine(value2);
}

static void SetString1(ref string value)
{
value = "dog";
}
static void SetString1(out string value)
{
value = "bird";
}

Output:
dog
bird