Monthly Archive » January 2010

Debug not working for Sharepoint

I had the problem of not able to debug Sharepoint in Visual Studio 2008 awhile ago, and glad that Aaron shown me how to do it by doing some tricks. What happened was the PDB file might not have been deployed to the assembly GAC.

What you do is:

  1. Start, Run, %systemroot%\assembly\gac, [ENTER].
  2. From there, go up one folder, then into GAC_MSIL folder.
  3. Paste the pdb file with the DLL, you will find yours amongst the folder names.

Restore list form web part for EditForm

Yesterday I spent the whole day finding on the Internet about how to restore the list form web part of my edit form as I accidentally deleted it and could never get it back from the Closed web parts, nor could I get it back by resetting the file to site definition in Sharepoint Designer. It is really important to remember that the original edit form, display form and new form should never be deleted, but kept as hidden if we had to customise them.

What happened after I deleted my edit form, caused the edit link to disappear in the display page, nor could I edit properties of any item, or it will just redirect to the AllItems.aspx page. So, to retrieve the edit form back, what we do is:

Read More

How to send email via Sharepoint

This is a useful function for sending a message via Sharepoint:

private void SendEmail(SPWeb oWeb, bool appendHtmlTag, bool htmlEncode,
            String toAddress, String subject, String message, bool elevated)
            //check if external email is set
            bool isExternalEmailSet = SPUtility.IsEmailServerSet(oWeb);
            if ((elevated == true) && (isExternalEmailSet == true))
            {//run elevated
                    SPUtility.SendEmail(oWeb, appendHtmlTag, htmlEncode, 
toAddress, subject, message);
            else if ((elevated != true) && (isExternalEmailSet == true))
            {//run un-elevated
                SPUtility.SendEmail(oWeb, appendHtmlTag, htmlEncode, 
toAddress, subject, message);

ScriptResource.axd from Ajax getting Too Big

Today I was testing the loading time of my site, which I sometimes find it slow to access especially the first time loading. I knew there are a lot of images to be loaded especially those in portfolio sections but I also found that the biggest loading item seems to be ScriptResource.axd from Ajax. It was 330kb!

Read More

Reading and Writing to Lookup Field in Sharepoint

Lookup field is a field which links a child class to a parent class, it is an association kind, which allows a list item to reference another item from another list. However, reading and writing to a lookup field is different from a normal field. We need to use the class SPFieldLookupValue to archieve this.

Read More

How to check if Constraint exist

A very useful statement to check if a constraint exists before do something to it. Note, we can never edit a constraint before deleting it and re-create.