Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [c-sharp]

C# is one of the programming languages designed by Microsoft for the Common Language Infrastructure.

1
vote
1answer
23 views

CSOM: How to know if a Web has completed its creation?

I have a service that creates a Sharepoint Online site using CSOM. context.Web.Webs.Add(webCreationInformation); context.ExecuteQuery(); This site is created using a defined Template stored in the ...
1
vote
1answer
68 views

Custom action not working in SharePoint 2019 on premise

I have a problem with a custom action in SharePoint 2019 on premise. The custom action adds a link in the menu item of the SharePoint menu bar. It's a mysite collection. SharePoint 2013 (it works): ...
1
vote
2answers
50 views

Upload Multiple Documents to SharePoint Online using C#

I've been trying for a while to make this work, but I'm stuck. I've checked all the solutions around here and google, but can't seem to figure out why I keep getting an error. string targetFolder = "/...
0
votes
1answer
43 views

Getting data from another website using C# and displaying in a web part

I'm trying to read information sitting in another wesbsite using C# and displaying the result in sharepoint 2010 web part. I read about httprequest but I'm failing to implement it. Please anyone help ...
1
vote
0answers
59 views

Modify the List View Web part's Miscellaneous ( Form Template Name ) value using C# in SharePoint 2016

Is there any way to change the List View Web part's Miscellaneous ( Form Template Name ) value using C# in SharePoint 2016
0
votes
1answer
47 views

getting all AD groups and users of a site collection

Hello everybody I am quite new to the Sharepoint, I am trying to get all the AD groups who have permissions on a sitecollection. I am able to get all the SPgroups and users using the code below in my ...
1
vote
1answer
186 views

Use HttpWebRequest with SharePoint Online and ADAL

I have a C# desktop application which uses ADAL and the SharePoint Online CSOM to access SharePoint Online. The CSOM methods all work great, but sometimes I use a HttpWebRequest when I need to resolve ...
0
votes
0answers
16 views

How to get and save pages to template when using GetProvisioningTemplate with SharePoint Online?

With SharePoint Online you can get template from site collection with ProvisioningTemplateCreationInformation ptci = new ProvisioningTemplateCreationInformation(ctx.Web); // Create ...
0
votes
0answers
182 views

RegionalSettings.TimeZone.LocalTimeToUTC resp. UTCToLocalTime wrong?! (CSOM)

I came across a weired problem with the LocalTimeToUTC/UTCToLocalTime functions of the TimeZone class (C#, CSOM v14.0.4762.1000). The results are just completely wrong. I couldn't find any other page ...
0
votes
0answers
197 views

System.InvalidOperationException: 'This property cannot be set after writing has started.' for OpenBinaryDirect

I am getting "System.InvalidOperationException: 'This property cannot be set after writing has started.'" when calling OpenBinaryDirect(). Please check below code and suggest. public static void ...
0
votes
0answers
53 views

Recursive SharePoint Online Top Navigation Menu Overlay

This is for SharePoint Online What I'd like to accomplish My SharePoint environment is expanding rapidly. I have several sites to build an it would make life easier if I could build a recursive ...
1
vote
1answer
31 views

Sharepoint Online, Getting the Versions of a document only returns older versions of the document and not the current

I am developing a desktop app in c# using CSOM to run against an o365 SharePoint solution. I managed to get the version, however in testing I have noticed that I am always getting the second newest ...
0
votes
1answer
20 views

Content Search Webpart is not displaying after adding ddl.ClearSelection()

I'm having issue on asp:dropdownlist and search result display. One of the issues is "Cannot have multiple values on DropDownList", so, I looked it up and most of the suggestion were the use of ...
0
votes
1answer
1k views

How to upload a document in a SharePoint list using Graph API

We have been trying to add a document to a list item using Graph API but are being thrown a 400 error :( We have the access token and can query the list in question without any problem. Below is the ...
1
vote
0answers
67 views

SharePoint 2010 Workflow: SPContext.Current.Web.URL returning Object reference not set error

I have a workflow that I have created for an SP 2010 site that does a basic approval process. In the workflow I have a couple of methods that create an email that is sent out to first the approving ...
0
votes
1answer
208 views

How to get default Pages folder programmatically in Sharepoint 2013

Using C# in Sharepoint 2013 I can reach Pages folder using web.Folders["Pages"] or web.GetFolder("Pages") Some of our SPWebs are in Turkish language. Whole interface is in Turkish including all ...
0
votes
2answers
29 views

Please advice on rewrite event receiver code on SP2010

Recently I need to take care an SP2010 farm which I am not familiar. There is an event receiver with part of code as below: SPListItemCollection ListA = properties.Web.Lists["ListA"].Items; List<...
0
votes
2answers
543 views

Programmatically move site to another site collection

In SP 2013, on prem, we need to move a sub site from one site collection to another - with all its permissions and versions of documents. I am thinking of writing this in a SharePoint timer job with ...
0
votes
1answer
1k views

I want to retrieve data from SharePoint list using c# and store them into SQL server DB tables. How can I do this?

using ( SPSite site = new SPSite ("http://somesite/sitename")) { SPWeb myWeb = site.OpenWeb(); SPList target = myWeb.Lists["YourListName"]; SPListItems items = list.Items; myWeb....
1
vote
0answers
504 views

Cannot invoke method or retrieve property from null object. Object returned by the following call stack is null. \“File\r\n\”

I am trying to edit an existing page with this code. When I am setting a publishComment it is throwing this exception. item["Title"] = pageTitle; item["PublishingPageContent"] = pageContent; item....
0
votes
1answer
26 views

Hide Wiki Page template from Site Actions>More Options in sharepoint 2010 programmatically

I want to hide the option of creating wiki page which is accessed via "Site Actions>More Options>Page" under Page type for all the users. I tried to find the display name and scope for deactivating ...
1
vote
0answers
25 views

How to Download files from a sub folder? COM

I am trying to make a method that will allow me to use the parameter for folderName to update the path of file location within SharePoint. However, I am having some issues with getting the proper URL ...
0
votes
2answers
2k views

How to Upload to SharePoint using a memory stream? Using CSOM

I am creating a method to UploadDocument_FromStream() method which has one parameter -- Stream file. I am having trouble trying to keep my SharePoint connection open to allow me to upload my Stream ...
1
vote
3answers
1k views

Creating a sub-folder in a SharePoint with Client.dll in C#

I am trying to create a list of all the folders that exist within the root folder. From there I want to implement the creation of a folder if the folder does not already exist. Is there a way to ...
1
vote
2answers
440 views

How to test if a SharePoint connect is successful with user credentials using Unit testing C#

I am working on a project where I am trying to test if a user has successfully logged in with valid credentials using the Microsoft.SharePoint.Client.dll. Currently my code is checking the HTTP ...
1
vote
3answers
1k views

Add resource assignment work by day

For a few days I'm trying to write the assignment progress for a specific task for a specific date. For example: I'm able to set the overall progress of the task but not the actual work that resource ...
0
votes
1answer
496 views

“Sign in as different user” code not working

I am trying to implement the functionality for "Sign in as different user" link button on my custom access denied page in sharepoint 2010 using the below code string site = base.Web....
0
votes
1answer
174 views

Facing Error while accessing SharePoint site list, The remote server returned an error: (401) Unauthorized

I am getting following error "The remote server returned an error: (401) Unauthorized." While I'm trying to read a website hosted in SharePoint. I have tried following code to access my ...
-1
votes
1answer
2k views

Status Code:500 Internal Server Error, while calling a webmethod in SharePoint 2013

I am trying to call a webmethod written on application page but getting an error, Status Code:500 Internal Server Error JavaScript: <script type="text/javascript"> $(document).ready(...
3
votes
1answer
49 views

Format data from multiple lists in Visual Web Part formatted like Standard List

I'm trying to roll data from multiple lists into one web part using Visual Studio, preferably a Visual Web Part. I want it to look like a normal SharePoint list view, with options to sort, filter, and ...
0
votes
0answers
463 views

Gridview Databinding method in sharepoint

I know I have done something wrong so I need some suggestion about writing the below code. protected void Page_Load(object sender, EventArgs e) { SPWeb web = SPContext.Current.Web;...
0
votes
1answer
55 views

Update link in GridView

I have written the below code for updating gridview, It's not working. protected void Update_row(object sender, GridViewUpdateEventArgs e) { try { //TextBox ID = (...
1
vote
1answer
74 views

Null Reference error in gridview code

While debugging I found that ItemID value is getting null. I am trying to get the list item's ID. ItemId = GridView1.DataKeys[e.RowIndex].Value.ToString(); Can anyone please tell me what could ...
-1
votes
1answer
249 views

sharepoint 2013 C# update people or group

I have a requirement to move few of the items from Calendar A to Calendar B. How do I copy the below column values from A to B using C#? Attendees, Free/Busy, Resources, CheckDoubleBooking, Category ...
0
votes
1answer
222 views

Creating Visual Web part for file upload

I am trying to create a visual web part to upload documetns using FileUpload control. Below is the working code for uploading a file. protected void UploadButton_Click(object sender, EventArgs e) ...
0
votes
1answer
2k views

How to get document item ID of a Document Library given Item Path - using c#?

I can't figure out how to get the item ID of a document library from the crawled or managed properties. So I decided to get it using the item Path which return the document Url allowing to download it....
0
votes
0answers
77 views

How do I get 2 lists to show next to each other using MVC web- application?

I know how to get one list from SP in my web-application, but I want to display 2 lists that I have in 2 div's. My problem is that Everything disappears when i run them with the code below: var ...
1
vote
1answer
521 views

How to query list from custom created web part

I have built a custom visual web part in c# for SharePoint 2010. What I would like to do is be able to query a specific list in SharePoint and then process the results. I am a complete noob when it ...
3
votes
2answers
117 views

Programmatically create a ContentDatabase C# SP2013

I am searching for a solution of my problem. I banged my head for the last few hours and tried several things and solutions found on google or stack-exchange. The database should be created via Event ...
6
votes
2answers
130 views

SPContentTypeId.Empty vs default

Is there any reason to prefer SPContentTypeId.Empty over default? Console.WriteLine(default (SPContentTypeId)); // writes 0x Console.WriteLine(new SPContentTypeId()); // writes 0x Console.WriteLine(...
1
vote
0answers
49 views

Copy all folders in a library to another library [duplicate]

I have a Sharepoint library which is having 10 folders, i want to move those folders(along with files inside those folders) from one library to another library with in same site using CSOM**(C#)**. ...
0
votes
0answers
174 views

People Picker in Client Object Model 2010

So I am trying to build an equivalent to a People Picker in Windows.Forms Application. Since 2010 does not have Web.SiteUsers like 2013 does I had to write it like this. public UserPicker(string ...
1
vote
0answers
52 views

SharePoint page refresh on server control click

I created a page with server side radiobutton and checkbox functionalities. But selecting every control, the page is refreshing. In this regard request to help me by suggesting an idea for rectifying ...
0
votes
1answer
881 views

SharePoint 2013 C# get all websites and sort alphabetically

I am currently building a visual webpart for an on premise SharePoint farm in C#. I am currently able to get all of the webs and also get all of the list items within each web, using the CAML Query I ...
2
votes
2answers
3k views

How to delete content type from a list using c# and scom

How can I remove a Content Type from a List ? I've found code for deleting from sites but not from Lists.