Showing posts with label how to. Show all posts
Showing posts with label how to. Show all posts

Wednesday, April 28, 2010

padding zero

Sometime when you need to append padding zero for a numeric figure. e.g. 0001, 0002 .

You might think to write your own 'sweet' logic to format the string. The good news is, .net out of the box gives you this feature.

string.Format("{0:00000}", yourIntegerValue);

Wednesday, February 3, 2010

Full-featured customer portal

Looking for how to build a full feature portal for scratch. Check out this video from asp.net.

It shows you how to do C.R.U.D. for a table in sql and datagrid using sqldatasource, and also the login control.

Wednesday, January 20, 2010

How to pass Guid variable to ObjectDataSource ?

I Spent one day to find out how to pass guid variable to objectDataSource, the error encoutered is

"Object must implement IConvertible"

The solution for this is to use


"< name="myGuid">" instead of

"< name="myGuid" type="String">"

Find out more from here

Monday, October 5, 2009

Enable Anonymous Access

How to enable anonymous access in SharePoint.

Tuesday, September 8, 2009

How to change theme when new site is created

Some of you have this requirement to create a new theme for your customer. And obviously this theme will be used automatically if a new site is created.

One of the stupid way is to include the step to change the theme as part of the operating mannual, but let me show you the tricks.

If you understand the concept of branding on how to change the .master page, you will find this theme changer feature is very similar.

What you need to do is to :
1. Create a new theme (i.e. NewTheme) and put it in 12hive\ Themese folder
2. Create a new .vb file which inherit SPFeatureReceiver and override FeatureActivated method to include the below coding.

Dim objWeb As SPWeb
objWeb = properties.Feature.Parent
objWeb.ApplyTheme ( " NewTheme " )
objWeb.Update()

3. The above is to ensure that newtheme is being switched when the code is feature is activated.
4. Compile it with strong name and deploy to GAC.
5. Package this .dll as feature
6. Locate the onet.xml for site template that you have 12hive\template\sitetemplates\SITE NAME\xml
7. locate to include the feature ID which you have created earlier.

The idea of this theme changer is very similar to branding.

Wednesday, July 15, 2009

SharePoint RSS

SharePoint RSS provides the flexibility to expose view as RSS feed. With this feature, we can perform filtering, grouping and etc. to aggregate the list data information in the list and expose it as RSS feed.

Follow this article to achieve it.

Tuesday, July 14, 2009

Survey on Publishing template for anonymous

You might experience access denied behaviour when you try to use anonymous access to response survey.

How this happen is because a feature called ViewFormPagesLockDown is activated for publishing site.

So the key is to deactivate this.

stsadm -o deactivatefeature -name ViewFormPagesLockDown -url yrURL

find out more from here

Tuesday, June 30, 2009

How to MASS remove item in list

The typical answer is to do a looping to remove all items one by one. This required multiple call to the server. Check out the following approach


private static StringBuilder BatchDeleteCommand(SPList spList)
{
StringBuilder sbDelete = new StringBuilder();
sbDelete.Append("< ? xml version=\ "1.0\" encoding=\"UTF-8\"?>");
string command = "" + spList.ID +
"< / SetList>{0}< / SetVar>Delete< / SetVar>< / Method >";

foreach (SPListItem item in spList.Items)
{
sbDelete.Append(string.Format(command, item.ID.ToString()));
}
sbDelete.Append("
");
return sbDelete;
}