.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Changing Document Property on Checkin Event

Posted By:      Posted Date: September 13, 2010    Points: 0   Category :SharePoint
Hi, I am creating an event , which has to change a custom property from second draft to PreFinalArtifact when a person chechins that file. I have userd the following code. public   override void ItemCheckingOut(SPItemEventProperties properties) {   base.ItemCheckingOut(properties);   if( properties.BeforeProperties.ChangedProperties.ContainsValue("Second Draft")) { properties.BeforeProperties.ChangedProperties.Remove( "Document Artifact Stages"); properties.BeforeProperties.ChangedProperties.Add( "Document Artifact Stages","PreFinal Artifact"); }   } It is not working and further When i attach all W3p process visual studio 2005 terminates.

View Complete Post

More Related Resource Links

How to write an event to manage permissions on a document while uploading, depending on custom field



I am trying to find a solution to manage permissions on a document, while uploading it into a document library. This event has to be fired if a custom field is populated (it's a check box field).

How to write an event for this, i tried writing ItemAdded event, but this is getting fired as soon as a document is uploaded, before coming to the page, where we populate all the fields and hit check in.

can i capture Check-in event.

Please advise.


How to get object from the gridview selectindex changing Event.


I have a grid view which is populating with a data source through databind. And the Datasource is list of objects.Now when the user selected a row I want to get the object of that row.

I'm trying to get the row like this.


r = gvTruckCarrier.Rows[e.NewSelectedIndex];


drv = r.DataItem as DataRowView




but the drv value is

Changing a textbox's readonly property right before update on a gridview


I have a gridview with a date field. I don't want the user to be able to type in their own date and mess up the format so I made the property readonly. That date is then set by a point and click interface. This is all working fine but when the user clicks update this field doesn't update because it's readonly. If i turn readonly off it works so is there a way to turn off the readonly property right before submit?

Changing fields while updating an InfoPath Form to a SharePoint 2010 Document library

My document library has following EventReceiver: <?xml version="1.0" encoding="utf-8"?> <Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <Receivers ListTemplateId="101"> <Receiver> <Name>EventReceiverDocumentLibraryItemUpdating</Name> <Type>ItemUpdating</Type> <Assembly>$SharePoint.Project.AssemblyFullName$</Assembly> <Class>EventHandling.EventReceiverDocumentLibrary</Class> <SequenceNumber>10000</SequenceNumber> </Receiver> </Receivers> </Elements> Updating a browser enabled InfoPath form in the document library fires following event: Public Overrides Sub ItemUpdated(ByVal properties As SPItemEventProperties) Try Me.EventFiringEnabled = False properties.ListItem("Lastname") = "Testperson" properties.ListItem.ParentList.ParentWeb.AllowUnsafeUpdates = True properties.ListItem.SystemUpdate(False) ' solution 1 properties.ListItem.Update() ' solution 2 properties.ListItem.UpdateOverwriteVersion() ' solution 3 properties.ListItem.ParentList.ParentWeb.AllowUnsafeUpdates = False Me.EventFiringEnabled = True MyBase.ItemUpdated(properties) Catch ex As Exception Me.EventFiringEnabled = True E

Event handler to delete minor versions in document libraries

Hi Is there a way we can capture the deletion of minor versions in document libraries using any event handler. May not be using the delete all the minor versions but at least when we use the option to delete the selected minor version. I do not see the ItemUpdating and ItemUpdated getting fired in this case. Thanks wpwije  

Word Document date property defaulting to an incorrect value.

Within a SharePoint document library we have a custom column that is a date (Inactive date). If you look at the properties from within SharePoint on a document the date is empty. If you open the document in Word 2007 and look at the properties the date has acquired a value, always the same value 30/11/1999. If you save the document and look at the properties in SharePoint again it now has the value.  Unfortunately in Business terms this now shows that the document is “In Active”. I traced the date back to the template document on the library. I edited the template document by removing the date and saving it. If I then create a new document and save it again the properties in SharePoint show an empty date. However if I then open the document again in Word the date appears. This problem does not occur with word 2003. How can I stop the date defaulting to this value when a document is opened in Word?

Rename a document in Doc Library without changing the modified by

How do I rename the document in the document library without changing the modifed by and no increment of version? My Document Library setting is Major Version and CheckOut is set to No. I'm using SPSecurity.RunWithElevatedPrivileges to rename the document I had tested to checkout then checkin but there is an increment in version. Here is a sample code that will rename the filename but the modified by changed to System Account. SPSecurity.RunWithElevatedPrivileges(new SPSecurity.CodeToRunElevated(delegate() { using (SPSite elevatedSite = new SPSite(SPContext.Current.Site.ID)) { using (SPWeb elevatedWeb = elevatedSite.OpenWeb(SPContext.Current.Site.RootWeb.ID)) { elevatedWeb.AllowUnsafeUpdates = true; SPList list = elevatedWeb.Lists["Library1"]; SPListItem item = list.GetItemById(documentID); if (updateFilename) item["Name"] = filename; item.SystemUpdate(); } } })); Is there anyone out there who can help? Thanks in advanced.

How to rename the document using event receiver during upload

Hi all, I am going to programmaticlly rename the document when it is being uploaded to the document library. In Visual Studio 2010, I used the event receiver and choosed the documment libray type, for the event I selected 'ItemAdding". However I am not able to update the file name using the codes inside this thread: http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/5c3dcc5d-3113-463d-8835-2a050b2471a6/ Can anyone help me with this problem? Thanks!

Changing the content type of a document

Hi everybody, Can we change the content type of a document ? For example, I have a custom content type 'A' that inherits from the default document content type. If I upload a document (on behalf of the windows explorer) and the default document content type is assigned, can I change it to the content type 'A' after ? Thanks in advance.Psyllos

Intercept Check-In Event of Document Library in SharePoint 2010

we need to intercept the default check-in Event of the Document Library. The detailed requirements is as follows.   1. Intercept the check-in Event of Document Library. 2. Instead of the default check-in  page (normally this is the layout's checkin.aspx page), show our custom application page. 3. In the custom application page, allow users to provide some inputs. Validate the input values against values stored in database. 4. Once validated successfully, allow user to check-in the documents. Else, do not allow user to check-in the document.   One more additional requirement is the above things should happen only for our custom content type. In order to achieve the same, we are planning for deploying our custom document content types and perform the above operations on check-in event of the documents.     Another approach of performing the same is , have our own custom ECB Menu. The detailed process is as below.   a. Customize the check in menu (ECB) b. Show the custom form and get the inputs from user and do the validations c. On the OK button click, if validation is success, then update the meta data and check in the document or deny the process. d. But in this approach, we need to check the libraries version settings and that default functionalities should be added automatically to the check in process.   At this point of time, we a

event receiver to update created field of uploaded document

Hi,   I need to update the created column with the document creation time . 1) First should i use ItemAdding event or Item Added event 2) how do i get the file created properties and assign it to the cdocument library created column.

DataPager: raise event when page changing


I have a ListView and a DataPager beneath.

When the page is changed I bind the ListView from the PreRender event handler:

    Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
        Dim postControl As Control = GetPostBackControl(Me)
        If Not postControl Is Nothing Then
            If TypeOf (postControl.Parent) Is DataPagerFieldItem Then
            End If
        End If
    End Sub

Is there any way of intercepting an event raised when the page is changed without relying on page.PreRender?

Can't deploy SharePoint solution even after changing Site Url property



I've developed a SharePoint 2010 solution in VS2010 and i've also deployed it on my site collection - everything works perfect, fine!

But when I try to deploy the same solution in another site collection (on local server not remote) by changing Site Url property of the solution to my new site collection, VS is not deploying the solution. I'm getting the following error:


Error 102 Error occurred in deployment step 'Recycle IIS Application Pool': Cannot connect to the SharePoint site: http://newsiteurl/. Make sure that this is a valid URL and the SharePoint site is running on the local computer. If you moved this project to a new computer or if the URL of the SharePoint site has changed since you created the project, update the Site URL property of the project.


I've packaged the solution and deployed it manually, it's working fine but i don't understand why i'm not able to deploy the solution on a different site collection on the same machine??

Does anyone else has experienced the same issue? 



Thanks & Regards,


How to Set System.Windows.Controls.WebBrowser.Document Property , navigatetostring,stream DONT WORK


Hi , i search in google , bing , cuil and all of searchs provider for the solution of this problem :


I get HTML content from HTTPWebRequest(because is much requests and if i use WebBrowser control directly i get a lag and video processing unnecessary)


And i need  set System.Windows.Controls.WebBrowser.Document with this text.


"Solution" , use new methods call NavigateToString() or NavigateToStream()

BUT THIS PROBLEM , both DON'T work with <javascript src="something.js"> or <style src="something.css">

Navigates ONLY read and process content INSIDE this tags , no external files (like 'something.js')

Solution i encountred after two weeks of search

Process the text and replace the files by the content of that.

But this i think that is no real solution. (i tested , work , but not perfectly) * I write my own code because that post dont have source code.

for why you need to do that?

because i need interact with users after search , and use html's input to re-search again and process this file with all extern files is too slow

Any solutions?

C# Lenguage

Sorry for bad english, i'am brazilian.


Changing the E-Mail Subject field in a Document Library


I am trying to use SharePoint Manager 2007 to change the Sealed attribute of the item to False, so that I can edit the E-Mail Subject field of items in an email enable library.  When I select False I get the error: "Operation is not valid due to the current state of the object.". 

Is there another way that I can change this attribute to False?

Getting SPRequest object was not disposed before the end of this thread in SP document library event


I am using a sharepoint event listener attached to a document library to export files when they are added or modified. Here is a partial stack trace from the SP log for the SPRequest object was not disposed:

This SPRequest was allocated at    at Microsoft.SharePoint.Library.SPRequest..ctor()     at Microsoft.SharePoint.SPGlobal.CreateSPRequestAndSetIdentity(SPSite site, String name, Boolean bNotGlobalAdminCode, String strUrl, Boolean bNotAddToContext, Byte[] UserToken, String userName, Boolean bIgnoreTokenTimeout, Boolean bAsAnonymous)     at Microsoft.SharePoint.SPWeb.InitializeSPRequest()     at Microsoft.SharePoint.SPFile.GetFileStream(OpenBinaryFlags openOptions, String etagNotMatch, String& etagNew)     at Microsoft.SharePoint.SPFile.OpenBinary(SPOpenBinaryOptions openOptions)     at Extract.SharePoint.Redaction.IdShieldFileListener.HandleSharePointFileEvent(SPItemEventProperties properties, FileEventType eventType)

Here is basically the code in the HandleSharePointFileEvent:

    public override void ItemUpdated(SPItemEventProperties properties)

Problem with the Document Checkin and Check out.


Hi all,

We have a webpage built on sharepoint 2010 platform and we are windows xp sp3 & windows 7,  IE 8 & IE7, msoffice 2007 sp2.

When ever i try to checkout and edit the document i get an error as


But, it works fine when the sharepoint designer is installed on the same system.

Request you people to assist me.



ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend