SharePoint Notes

Workflow Code Snippets

When the workflow code snippets are not loaded in Visual Studio (especially VS 9.0),

1. Go to Tools > Code Snippets Manager
2. Change the language to XML
3. Add
- Workflow snippet for VS 8.0:
  %Program Files%\Microsoft Visual Studio 8\Xml\1033\Snippets\SharePoint Server Workflow
- Workflow snippet for VS 9.0:
  %Program Files%\Microsoft Visual Studio 9.0\Xml\1033\Snippets\SharePoint Server Workflow

If you have done the instruction, go back to your feature or workflow xml file and press Ctrl + K, X and select SharePoint Server Workflow then you could see five options you can select. They are Element File Tag, Feature.xml Code, Modification Form Tag, Task Form Tag, Workflow.xml Code.

Even though I installed OfficeServerSDK.exe but the workflow code snippets are not loaded automatically on Visual Studio 9.0 (2008). I looked through paths between 8.0 and 9.0 and I found out the SharePoint Server Workflow folder wasn’t copied to 9.0. So I just copied it to 9.0 and done!!! It worked as I expected.

If you didn’t install VS 8.0 on your pc then you can post your comment here then I’ll upload those files into zip for you. Or maybe there is a SDK for VS 9.0 so you can search on MSDN downloads.

캐나다 생활 관련 참조 사이트

1. 영문 주소 변환 서비스
 - 우정사업본부 > 국내 우편 온라인 조회 이후 검색어에 해당사양 입력
 - http://www.koreapost.go.kr/servlet/kpp.post.PostInfo

2. Human Resources and Skills Development
 - SIN 에 관한 정보를 얻을수 있습니다.
 - http://www.hrsdc.gc.ca/en/cs/comm/hrsd/whats_new.shtml
 - http://www.hrsdc.gc.ca/asp/gateway.asp?hr=en/cs/sin/030.shtml&hs=sxn#q1

3. Canada Map
 - http://listingsca.com/maps.asp

4. TravelCanada - 캐나다 관광청
 - 캐나다 정보 파악엔 최고의 사이트
   각 주와 해당 지역에 따른 설명과 Culture, Festival & Events, Outdoor,
   Touring, Winter 등 Travel Plan 쓰기에 좋은 website 입니다.
 - http://www.keepexploring.ca/tc_redesign/app/en/ca/home.do

5.  About Toronto
 - Toronto 에 대한 정보를 얻을때
 - http://www.torontotourism.com/Visitor

6. Winnipeg.ca
 - When I want to find about information of Winnipeg
 - http://www.winnipeg.ca/census/2001/

Attach JavaScript Functions to the onload event of body on SharePoint pages

As you all know that SharePoint is tricky to do things in comparison with Plain ASP.NET. Even though it's not easy but if you study it instead of implement what you want yourself, you can use functions which SharePoint provides and one of them is "spBodyOnLoadFunctionNames array" which is SharePoint provides a way to add your events to onload. Here's a usage below.


// Usage


If you didn't know about it or if you want that onload event but you need to implement then use this below.
From JavaScript: The Definition Guide, Flanagan, O’Reilly


 * runOnLoad: portable registration for onload event handlers.
 * this source from JavaScript, The Definition Guide,  Flanagan, O'Reilly
function runOnLoad(f) {
    if (runOnLoad.loaded) f();    // If already loaded, just invoke f() now.
    else runOnLoad.funcs.push(f); // Otherwise, store it for later
runOnLoad.funcs = [YourFunctionToAdd]; // The array of functions to call when the document loads
runOnLoad.loaded = false; // The functions have not been run yet.
// Run all registered functions in the order in which they were registered.
// It is safe to call runOnLoad.run() more than once: invocations after the
// first do nothing. It is safe for an initialization function to call
// runOnLoad() to register another function.
runOnLoad.run = function() {
    if (runOnLoad.loaded) return;  // If we've already run, do nothing
    for(var i = 0; i < runOnLoad.funcs.length; i++) {
        try { runOnLoad.funcs[i](); }
        catch(e) { /* An exception in one function shouldn't stop the rest */ }
    runOnLoad.loaded = true; // Remember that we've already run once.
    delete runOnLoad.funcs;  // But don't remember the functions themselves.
    delete runOnLoad.run;    // And forget about this function too!
// Register runOnLoad.run() as the onload event handler for the window
if (window.addEventListener)
    window.addEventListener("load", runOnLoad.run, false);
else if (window.attachEvent) window.attachEvent("onload", runOnLoad.run);
else window.onload = runOnLoad.run;


but the above one is much simple and easy to use in SharePoint. You can use this for regular HTML or .NET pages.

Guid.ToString(”B”).ToUpper() means???

When you want print out GUID like this format
{855F9A70-9A43-435B-A5B1-B91A7F58BAD1} => bracket surrounded….
you can use that one.

For example, Guids of SPlist or SPField  

[Sample Code here]:

string strGuid = "0b51264d-baa6-49dc-8970-1d24979053ac";
Guid guid = new Guid(strGuid);
string guidBTest1 = guid.ToString();
string guidBTest2 = guid.ToString("B").ToUpper();
Response.Write(guidBTest1 + "");


[In Detail]
The format parameter can contain the following format specifiers. In the table that follows, all digits in the return value are hexadecimal. Each character ‘x’ represents a hexadecimal digit; each hyphen (’-'), bracket (’{', ‘}’), and parenthesis (’(', ‘)’) appears as shown.

SpecifierFormat of Return Value
N 32 digits:
D 32 digits separated by hyphens:
B 32 digits separated by hyphens, enclosed in brackets:
P 32 digits separated by hyphens, enclosed in parentheses:

The provider parameter is reserved for future use and does not contribute to the execution of this method. A null reference can be coded for this parameter.

- Reference from http://msdn.microsoft.com/en-us/library/s6tk2z69.aspx

Using aspnet_regiis

ASP.NET IIS Registration Tool (Aspnet_regiis.exe)

Refer: http://msdn.microsoft.com/en-us/library/k6h9cz8h(VS.80).aspx

under %windir%\Microsoft.NET\Framework\v2.0.50727
or v1.1.4322. aspnet_regiis command can be used to install or update frameworks

When I need to choose ASP.NET Versions between v1.1 and v.2.0 on ASP.NET tab of Default Web Site Properties in IIS Manager but I can't see v1.1 so that I used the command to install v1.1.

> aspnet_regiis -i

By the way when I use the command with -lv parameter, I can see the output below

1.1.4322.0 Valid ...
2.0.50727.0 Valid (Root) ...

The problem is that I want to switch Root to v1.1 and there is a way to do it.

> aspnet_regiis -sn W3SVC/ (means default:Root)
sn : install scriptmaps for this version at the specified path, non-recursively

after that you could see the changes and using sn option, you can change scriptmaps by site. ie) -sn W3SVC/1/ROOT, W3SVC/3/ROOT ...
plus, -lk option with the command you can see IIS metadata keys affected.

Grant user or group to the IIS metabase and other directories

After you create a new website or virtual directory and browse a aspx file,
you might have error such as...

The current identity (NT AUTHORITY\NETWORK SERVICE) does not have write access to C:\WINDOWS\Microsoft.NET\
Framework\v2.0.50215\Temporary ASP.NET Files'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

You can grant access to this account explicitly using the aspnet_regiis -ga switch,
for example:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50215>aspnet_regiis -ga "NT Authority\Network Service"

aspnet_regiis -ga
Grant the specified user or group access to the IIS metabase and other directories used by ASP.NET.