where to add the c sharp code in this example to make changes in sharepoint programmatically? - sharepoint

i am trying to programmatically do some changes in sharepoint as per the link below
in the link below there is a the second cod snippet is a C sharp code. where do i put this code ? or how can i use this code in sharepoint is not mentioned .. can anyone please tell me ?
http://weblogs.asp.net/wesleybakker/archive/2009/03/05/select-multiple-list-items-in-sharepoint-feature.aspx

I haven't tried any of the code out in the post you linked to, but it looks like the C# code just needs to be compiled into an assembly and deployed to the SharePoint server.
The <CustomAction> element in the feature XML below the C# code references this assembly via the ControlAssembly attribute and the compiled class is referenced by the ControlClass attribute.
If you're adapting the code in the post and creating your own project, ensure that your assembly and class names are correctly referenced in the feature XML file (through the ControlAssembly and ControlClass attributes).
Alternatively you can download the author's SharePoint Solution Pack which contains this feature and others.

you should create a new program to call the method

Related

Revit API: NewFamilyDocument - where to get the template?

My code doc.Application.NewFamilyDocument(template_path); requires a path to a Revit family template. Currently we made a copy of, say "Metric Mass.rft" and redistribute this.
Is there a way to either/or
get the default path for these family templates
create a family document without the template
instead?
The default library paths are accessible via the GetLibraryPaths method. For examples of using it, please refer to the Revit SDK samples, e.g., RoutingPreferenceTools, UIAPI, RevitCommands, and The Building Coder samples external command CmdLibraryPaths, described in the article on Library Paths
.

Biztalk template with non-static namespace - Visual Studio

I've exported an orchestration template using Visual Studio 2012, based on one I previously constructed. It generates a .zip with the following .vstemplate file:
<VSTemplate Type="Item" Version="2.0.0"
xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
<TemplateData>
<Name>TESTOrchestration</Name>
<Description>Custon Orchestration</Description>
<Icon>Icon.ico</Icon>
<ProjectType>Biztalk</ProjectType>
<DefaultName>TESTOrchestration.odx</DefaultName>
</TemplateData>
<TemplateContent>
<ProjectItem TargetFileName="$fileinputname$.odx" ReplaceParameters="true">Orchestration.odx</ProjectItem>
</TemplateContent>
Using this item template in VS2012 creates an orchestration with the properties shown in the fig. below.
Notice the namespace is that of the original project from which the template was exported.
I want to set the default namespace of this item to include the project name (or even better the path leading to this item within the project). After searching I've yet to find a working example of how to accomplish this in a BizTalk item, namely an .odx.
Thank you for taking the time to read my question. I really hope you will be able to help me with this.
After searching and tinkering around I found out how to accomplish this.
When you export a template from Visual Studio two files are created, a .vstemplate and a template of the exported item, in this case a .odx. In order to alter the namespace, and other attributes, you need to edit this second file and add the information you want.
It is also possible to pass dynamic values by using template parameters in the form of $parameter$, which are documented in Microsoft's library.
So, for example, if you wanted to modify the namespace to include the project name, you would have to edit the exported .odx file and add the parameter $safeprojectname$ or $rootnamespace$ to dynamically set the namespace uppon creation of a new item based on the template.

How to fix SPFeatureDefinition does not contain a definition for RootDirectory

I'm very new to SharePoint development, and I'm just trying to add an XML file to a Feature to reference the XML file content in the feature Event Receiver.
It seems that the general recommendation is to use do so like in this SO question:
How to retrieve data from an XML file in a Sharepoint 2010 Feature Event Receiver?
However, my code does not compile when I reference the RootDirectory property. The error I see is below
'Microsoft.SharePoint.Administration.SPFeatureDefinition' does not contain a definition for 'RootDirectory' and no extension method 'RootDirectory' accepting a first argument of type 'Microsoft.SharePoint.Administration.SPFeatureDefinition' could be found (are you missing a using directive or an assembly reference?
Now, the weird part is that while debugging, I am able to evaluate the RootDirectory property correctly in the Quick Debug window.
Am I missing something obvious? Like I said, I'm completely new to SharePoint.
My feature is scoped to the Web level, and I do have a reference to Microsoft.Sharepoint.Administration in my using statements.
Any help is greatly appreciated, thanks.
It was indeed something very basic.
The solution/project was set as Sandboxed. Just going to the properties of the project (not the property pages but hitting F4 while the project is selected on Solution Explorer) and setting Sandboxed to false will let you compile when you're accessing the RootDirectory solution in code.
Also, a few other properties/method not show up when the solution is Sandboxed instead of marked as a Farm solution.

Sharepoint Infopath form - How to tell if custom code eixsts

I'm working with a Sharepoint project that was migrated from 2007 to 2010. There is not history on who originally created the project or how they did this. So, if the original developer used a Visual Studio project to add custom code to the form, that VS project does not exist.
Is there any way to tell if an existing form has custom code written for it? If I want to add my own custom code, the only way I can do this is go into the form properties and select "remove existing code". Then I can create a new project and add code.
Is it the case that if I cannot find the original VS project, that this is my only choice...to remove any existing code?
Yes, if you can't find the original project, then you're out of luck - you have to remove the code and rewrite as necessary.
http://www.bizsupportonline.net/blog/2013/recover-make-changes-infopath-forms-sharepoint.htm
(Paragraph at the bottom of the article, just before "3 ways you can find out whether code was written for a form template")

How can I add Classes from a referenced C# Assembly to a ClassDiagram in my current project

I have a referenced assembly that has a (devart) Linq Datacontext in it. We use this same assembly in a bunch of other projects and I don't want to add the source code to my current solution.
How can I add some of the classes in it to a ClassDiagram in my current project?
EDIT in Response to Comments/Answers
I don't have access to the original source code of the external project.
What I mean't was when I said "I don't want to add the source code to my current solution." was I don't want to build up a bunch of partials in my current solution either.
Include a reference to the library in your project.
Go to the object browser (View->Object Browser) and search for your class.
Drag and drop it from the object browser onto the design surface.
I tried it with System.Random and it pulls all the properties and methods.

Resources