Thursday, September 24, 2009

How to refresh application pool without resetting iis

This is the common scenario in sharepoint development. Suppose if you modify site definition file(xml) or you need to deploy the latest dll in GAC, then iisreset is must to get the changes.
But the thing is if the deployment is in production server then your customer may raise a issue. If server contains more than one application then its bad idea to give iisreset. Instead of that you can reset the application pool where your application is running.
For this we require the application pool id. How to get the application pool id?
Type the below line of text in command prompt.
C:\windows\System32\iisapp
This will display all the application pool id. Easily you will come to know about your app pool Id.
Next step is to refresh the application pools.
Type the following line in command prompt, that will refresh the app pool.
C:\windows\System32\iisapp.vbs /a “ApplicationName” /r
Another way is create one batch file and paste the following line of code.
C:\windows\System32\iisapp.vbs /a “ApplicationName” /r
pause

Wednesday, September 23, 2009

Deleting Items in a sharepoint list

How to delete items in sp list?
Whenever we are thinking about this scenario, suddenly the code comes in the mind is create foreach loop and loop through each items and delete the items.
But the problem is we cannot the the list items by this way. It will give the error like "Collection was modified; enumeration operation may not execute."
So to overcome this problem we need to write the code in differently.

int iCount = list.Items.Count;//Its allways better practice to assign the the count to some variable if we use list.Items.Count in for loop it will get the count record from database as many times as for loop will run.
int j ;
for(int i=iCount-1; i>=0;i--)
{
j = i;
list.Item[j].Delete()
}

Same logic will be applied to all share point collection.

Tuesday, September 22, 2009

Event Handlers

Difference between workflows and event handlers

1) Event handlers will trigger automatically where as workflows can be in either way.

2)User interaction is not there in event handlers where as opposite in workflows.

3) Event handler run for short duration where as workflows run for long duration

4) Workflows will be avalable after system down(maintainace,IISRESET etc) but this is not possible in event handler

There is no event for site created but site deleting and site deleted events are available.

To handle/run some custom code whenever a site is created.
Create a Feature that has an Event Receiver defined on it and call the Feature activation event.(There we can run code) Then, use a Feature Staple to staple your Feature to the GLOBAL site definition.

Friday, September 18, 2009

Sharepoint Development Links

In this blog i am providing only the links and good articles where it will be usefull for sharepoint developers and also some code snippets to do an workaround.