Hot answers tagged

7

There's not a huge difference for all of them. 3 out of 4 of them are server-side controls. And the SharePoint:InputFormTextBox and wssawc:InputFormTextBox are the exact same, only the prefix namespace (i.e. SharePoint, wssawc) is the difference. SharePoint/wssawc:InputFormTextBox has built-in co-operative field validation, the others don't. That's the ...


5

Using JSOM in the past I have experienced this trouble when I have a lack of system resources, specifically when my systems RAM has less than 5% available. The fact that you are getting a Service Activation Exception leads me to believe this may very well be the case, and can be verified in Windows event viewer. Close some applications or disable some ...


4

You should always select your list based on the URL, as the Title is more likely to change. And don't do SPWeb.Lists as this will enumerate all lists on the web site. Use this similar snippet instead: public Guid? GetListId(string siteUrl, string listUrl) { using (var currentSite = new SPSite(siteUrl)) { using (var currentWeb = currentSite....


4

You need to load webpart properties before you can read them. That is, var properties = webPart.get_properties(); currentCtx.load(properties); Then read the properties in success method. currentCtx.executeQueryAsync(...


4

Set Always Force Install to True in for your feature. (Assuming you are using Visual Studio)...Check the feature property window and you should see this option! If you are using PowerShell, you can also use : $sln = Add-SPSolution mySolution.wsp Install-SPSolution -Identity mySolution.wsp -GACDeployment -Force


3

Which event is your Event Receiver trigging on? Because the -ed receivers are asynchronous by default (which could explain the behavior you're seeing). So, either use ItemUpdating event for your receiver, or explicitly mark your ItemUpdated receiver as synchronous (in the XML or code based on how you are adding the receiver) For XML: https://blogs.msdn....


3

Use the tools the platform gives you. This is built in functionality on libraries. Go to your library settings and click on Versioning settings. Enable content approval. Now click on Workflow Settings. Then click Add a workflow. Configure a *Approval - SharePoint 2010 workflow as desired, also ensure you tick the box to "Start this workflow to approve ...


3

Try the following: using (SPWeb web = new SPSite(siteurl).OpenWeb(weburl)) { SPList list = web.Lists.TryGetList("MyList"); SPQuery query = new SPQuery(); query.Query = "<OrderBy><FieldRef Name='ID' Ascending='TRUE' /></OrderBy>"; SPListItemCollection collection = list.GetItems(query); MyDropdown....


3

you can create a separate Project eg. "Common" where you include those classes. You can reference that assembly than from your other Projects. Of course, you have to ensure that this wsp is installed along your other wsps (which use that dll)


2

You can get (or set) the selected value from code-behind (e.g. when user clicks a button) with myDateTimeControl.SelectedDate. EDIT: See https://karinebosch.wordpress.com/sharepoint-controls/datetimecontrol-control/ for examples (SharePoint 2007, but still relevant in 2013).


2

It same as you do in C# .net. In your button click event, define a connection string and then insert command. For eg. Sqlconnection con=new Sqlconnection(); con.Connectionstring="Data Source=PHANNY-PC\PHANNY; Initial Catalog=db_stuRegisterPay; Integrated Security=SSPI"; string query="insert into Persons_info(perID, latinName, gender, dob, pob, phone, ...


2

There are 3 List Templates for Tasks: Project (Gantt) Tasks (TemplateId: 150) Tasks (2010) (TemplateId:107) Tasks (TemplateId: 171) Did you verify that the requested List is using the Template you ask for?


2

Try this method: Without attachment using SPUtility. private Boolean SendEmail() { try { bool flag = false; SPSecurity.RunWithElevatedPrivileges( delegate() { using (SPSite site = new SPSite( SPContext.Current.Site.ID, SPContext.Current.Site.Zone)) { using (SPWeb web = site.OpenWeb(SPContext.Current....


2

To access SP.WebParts.WebPart Properties it need to be requested explicitly. In your example you could change the expression at the line: currentCtx.load(webPartDefs, 'Include(WebPart)'); with currentCtx.load(webPartDefs, 'Include(WebPart.Properties)'); Modified example var currentCtx = SP.ClientContext.get_current(); var pageFile = currentCtx....


2

It all depends on the code you run on the button click. Can you please share it with us? It's more than probably something done by your code, and your user does not have permissions to perform the action. e.g. you create a list item by code, while your "read-only" user obviously cannot create items... If you really need to take some actions on behalf ...


2

You can use the following code using(SPSite oSite = new SPSite("site url")) { using(SPWeb oWebsite = oSite.OpenWeb()) { SPList oList = oWebsite.Lists["Tasks"]; SPListItem oListItem = oList.Items[5]; oListItem["Title"] = "Some Title"; oListItem.Update();// without this line item will not update } } Read more ...


2

SPGridView can be customised to make it look similar to list view. For filtering and sorting you need to code and handle OnSorting and OnFiltering events. http://www.c-sharpcorner.com/UploadFile/b8e86c/pagination-sorting-and-filtering-in-spgridview/


1

You are not elevating in a correct way, you need to create new objects for SPSite and SPWeb. But since you use the root web, as you do, you do not need to explicitly create a new object for that, so you can do the below SPSecurity.RunWithElevatedPrivileges(delegate() { using(SPSite spsite = new SPSite(SPContext.Current.Site.Url)) { SPWeb ...


1

I haven't done radio buttons before but I have done checkboxes. Create a property for each checkbox field: [Category("Category"), WebDisplayName("Division"), WebBrowsable(true), Personalizable(PersonalizationScope.Shared)] public Boolean Division { get { return _Division; } set { _Division = value; } }


1

Do you see any "Toolbox" in the visual studio? If not, make it visible from the view menu. There should be a control called "Radio button list" which you could add directly to the designer surface. Or you could modify the aspx markup to add radio buttons. In any case, if you are familiar with .Net development, it is quite simple.


1

Let's see how the page should work. When you select a web part in the Add Web Part gallery, a preview of the web part is displayed on the right panel (it would appear where the error message is). This means that SharePoint has to render a part of the web part to be able to display such preview - this is why the OnInit method is run. As for the .IsPostBack ...


1

To work with server , you can't use another machine to deploy solution. You must need to login to server and develop solution there only.


1

Adding attachments to list items is completely different than uploading files to a doc lib. You first need to get a reference to the SPPListItem you want to attach to, and then you use myListItem.Attachments.Add. Here's a sample of code that may help you: it attaches multiple files (from local drive instead than from the UplaodFile control, but the story is ...


1

You have to store a string that serializes all your values. Obviously, since the string has now a special meaning, WebBrowsable only won(t do the magic to translate it into a nice selection UI. To handle the UI to display/set values in this string, you'll need to develop your own Tool part. You'll find a lot of examples on the Web, e.g.: https://msdn....


1

I am going to go ahead an answer this to save some poor soul in the future. The problem was with the App Manifest file. I had the Permissions => Scope set to Site Collection. This needs to be changed to 'Web'.


1

Could you not use the built in sharepoint utility: SPUtility.SendEmail(SPContext.Current.Web, false, false, "ss@test.com", "subject", "body"); SPUtility.SendEmail Method


1

As it turns out this was the problem with SharePoint 2013 and update panel You can read about the exact problem and available workarounds in the following technet forum: https://social.technet.microsoft.com/Forums/systemcenter/en-US/c33d4a46-87d6-4dbc-a24c-cb8e5f9eb1ea/page-refresh-after-postback-from-updatepanel-in-sharepoint-2013?forum=...


1

Based on the comment, Exception arises when folder does not exit. So solution is following if (!System.IO.Directory.Exists(folderpath)) { SPSecurity.RunWithElevatedPrivileges(delegate() { System.IO.Directory.CreateDirectory(folderpath); } Needs to check the folder if it exists before writing file....


1

In case this works on your DEV machine, but not in other environments, ensure the folder exists on all WFE servers of the farm (if there are many), as the code may be executed on any of them.


1

Found out the answer. Apparently, it is possible to do this using Machine Translation Services. You can call the service on demand and it'll translate the text for you. Found the code in msdn. The examples here only dealt with files, so modified it a bit to work with strings. SPServiceContext sc = SPServiceContext.GetContext(new SPSite("site")); ...



Only top voted, non community-wiki answers of a minimum length are eligible