Quantcast
Viewing all 11571 articles
Browse latest View live

add discussion board webpart programmatically to page

Hi,

I'm trying to add a webpart programmatically to a webpage.

Overally, it works well but I'm experiencing a weird issue when I'm trying to "embed" a discussion list into a page.

Usually, when I add programmatically a list or document library webpart into a page, it displays the page correctly with the html body and the webpart is added at the top or bottom of the page.

When I add programmatically a discussion list webart into a page, the result is different. When I open the page, I'm redirected to the discussion library instead of displaying the page with the webpart inside.

ex: I open https://siteremoved.com/migration/_layouts/15/start.aspx#/SitePages/Home.aspx

and it opens instead https://siteremoved.com/migration/_layouts/15/start.aspx#/Lists/Recent%20Announcements/AllItems.aspx

I tried tons of code during a few days, tons off different approaches and the result is always the same.

Most opf the code comes from https://github.com/OfficeDev/PnP/blob/master/Samples/Core.ModifyPages/ModifyPagesWeb/LabHelper.cs

I'm running out of ideas.

Can someone guide me to the right direction?

Thanks.



-- Emmanuel Dreux http://www.cloudiway.com


Webpart and zoneid

Hi,

consider the code below:

How do I find the value of zoneID that must be passed to the function AddWebpart?

When I set the default value "wpz" as referenced in several places in Internet, the webpart is not visible in the page.

When I replace it by "left" for example, the webpart is displayed in the page but not at the emplacement I'm willing.

I have found this interresting article ( http://blog.mastykarz.nl/programmatically-adding-web-parts-rich-content-sharepoint-2010/) that mentions to add the div section in the html code:

"<div class=\"ms-rtestate-read ms-rte-wpbox\" contentEditable=\"false\"><div class=\"ms-rtestate-read {0}\" id=\"div_{0}\"></div><div style='display:none' id=\"vid_{0}\"></div></div>"

And then add the wepbart by calling :  wpmgr.AddWebPart(cewp,"wpz", 0);

When I do that, the webbart is not displayed (but I can see that it has been correctly inserted in the page). It's just that it is not displayed/rendered.

Question: When I grab the html content of a page, and find the div section used to render the webpart, how do I determine the name of the zoneID that I should use programmatically?

 
        
       

 public void AddWebPartToWebPartPage(Web reqWeb, WebPartEntity webPart)
        {
            var webPartPage = _CurrentWebpage;
            LimitedWebPartManager limitedWebPartManager = webPartPage.GetLimitedWebPartManager(PersonalizationScope.Shared);
            reqWeb.Context.Load(limitedWebPartManager.WebParts,
                wps => wps.Include(
                wp => wp.WebPart.Title,
                wp => wp.WebPart.ZoneIndex));

            reqWeb.Context.ExecuteQuery();
            bool webPartExist = false;
            foreach (WebPartDefinition webpart in limitedWebPartManager.WebParts)
            {
                if (webpart.WebPart.Title == webPart.WebPartTitle)
                {
                    webPartExist = true;
                    break;
                }
            }

            if (webPartExist == false)
            {
                WebPartDefinition oWebPartDefinition = limitedWebPartManager.ImportWebPart(webPart.WebPartXml);
                limitedWebPartManager.AddWebPart(oWebPartDefinition.WebPart, webPart.WebPartZone, webPart.WebPartIndex);
                reqWeb.Context.ExecuteQuery();
            }
        }



-- Emmanuel Dreux http://www.cloudiway.com



Error: Scope in your query does not exist...

I have an advanced search web part on my page, and wanting to narrow the search scope to my particular site. In trying to accomplish this, I have created a scope in central admin, and modified the Advanced Search web part properties xml to reflect the scope I created. Within the ResultType tag of that xml, I have this to specify my scope

<KeywordQuery>&quot;scope&quot;='This Site'</KeywordQuery>

After doing this, I attempt a search, but I am getting the following error "Scope in your query does not exist". Am I missing anything? Has anyone ran into this previously? If so, I would appreciate your insight...I have not been able to find any blogs on this issue. This is on SharePoint 2010.

Thanks


Show Loader Image on Upload dialog of SiteFeed

Dear Experts,

I am using Site Feed on my site. I am having a problem on iphone, samsung s4, that when I click on Camera icon to upload the image and click on upload. the popup didn't show any progress indication or image that image is being uploaded. when image uploads after some time popup went off.

I need to show loading image or some progress indicator that document is uploading.

Kindly guide in this regard.


HBkhan

"Table of Contents" web part - How to have expand/collapse buttons? (I can use only CSS/JavaScript/JQuery)

Hi there,

I have a Table of Contents web part which is great. Is there a way so it shows only top level sites and then one can expand or collapse any top level site to see/hide the subsites?

As of now it shows

HR Parent site
- HR sub site 1
- HR sub site 2
IT Parent site
- IT sub site 1
- IT sub site 2

What I want is 

+ HR Parent site
+ IT Parent site
So one can expand or collapse on demand.

Any relevant JS/CSS/JQuery code?

Thank you so much.




ASP Drop down list issues while trying to connect to SQL

I'm using SharePoint 2010 and SQL 2012. On the aspx page that I designed in SharePoint Designer, I'm trying to setup a drop down list and connect it to SQL table. During wizard setup, I can see all the values and everything working (very simple small table, 2 columns with ID and description, less than 20 rows). When I try to preview the page in the browser, I get "This control does not allow connection strings with the following keywords: ‘Integrated Security’, ‘Trusted_Connection’” message.

I found the link that addressed the issue and tried the solution number 1 - see link below

http://www.randomizzzer.com/2011/02/how-to-troubleshoot-error-message-this-control-does-not-allow-connection-strings-with-the-following-keywords-%E2%80%98integrated-security%E2%80%99-%E2%80%98trusted_connection%E2%80%99/

However now I'm getting an error "Type 'System.Web.UI.WebControls.SqlDataSource' does not have a public property named 'AllowIntegratedSecurity'" - in design mode and error "Cannot create an object of type
'System.Boolean' from its string representation '”True”' for the
'AllowIntegratedSecurity' property.
" in a browser.  But that is what the link above suggests to do and my code is pretty much identical to the one listed in that link

<asp:SqlDataSource AllowIntegratedSecurity=”True” runat="server" ID="SqlJob" and so on...</asp:SqlDataSource>

The suggestion number 2 from that article won't work for us, as the company will not want to globally allow Integrated Security. Am I missing something? Are there other steps that I need to take to address it or any other solution?

The management doesn't want to hardcode the drop-down list in any way and opposed to use it as SharePoint list. Any ideas would be appreciated.


Alla Sanders




PowerPivot part of the Site is slow

 When going to the PowerPivot of my site in sharepoint, it is slow, it takes a long while for the silverlight to show the different PowerPivot reports there.  The animated circle spin for a very long while.

    How to speed up the rendering of the PowerPivot in Sharepoint?

-- IBM has jobs for USA employee to work oversea (India) and get their wages.

Data to be copied from Document Library TO Custom List

I want to design a Visual Studio application that can copy data from a  Document Library and paste it into a Custom List. There is a Document Library with a Content Type. We want users to click a button on the SharePoint 2010 site and that will  populate a custom List with same data as document library. So I can deploy a web part.

Both Document Library and List exist and have same columns. But the VS program has to populate the List with data in Document Library. Some validation will be required such as don't put duplicate data into the list.

Any sample code will help. Can this only be done via Visual Studio?

Thanks a bunch!!!

Mayank


Web Part Error:Sandboxed Code Execution Request Failed. Sandboxed webpart failing when gridview data size is large

Hi,

I have a sandboxed webpart, which displays list data in a gridview.Now, When the data is small(few items), the webpart works fine.

But when their is a large collection of items, following hapens.

1) On page load, the webpart works very well, showing all the records.

2) But, on any postback action(even when i click edit page), webpart fails and gives this error:

Web Part Error:Sandboxed Code Execution Request Failed.

 

Can anyone comment on this?


Check if Folder is available

Hi,

I have written below code to check if the folder exists in the site.

Through folder is available still it is displaying as 'Folder does not exists'.

Please check if i am making any mistake here

                               

using Sy

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

using Microsoft.SharePoint;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            using (SPSite site = new SPSite("http://servername:1268/sites/sitecoll/WikiSite/"))
            {
                using (SPWeb web = site.OpenWeb())
                {
                    if (web.GetFolder("General").Exists)
                    {
                        Console.WriteLine("Folder exists");
                    }
                    else
                    {
                        Console.WriteLine("Folder does not exists");
                    }
                    Console.ReadLine();
                }
            }
        }


    }
}

Regards,

Sudheer


Thanks & Regards, Sudheer


File Count with selected date range

Hi,

Our requirement is to get the file count with selected date by the user from two date time picker controls i.e. dtp1 and dtp2 into the data table. I am able to get the file count of specific folder from Pages library through below code. Now need to get the selected date range from two date time picker controls and check with the item created by is within the date range. If yes I need to get the file count.

So please share your ideas/thoughts to do the same.

SPList list = wikiweb.Lists["Pages"];

                    SPFolderCollection oFolders = list.RootFolder.SubFolders["foldername"].SubFolders;

                    DataTable dt = new DataTable();

                    dt.Columns.Add("Column1");

                    DataRow dr;

                    if (oFolders.Count> 0)

                    {

                        foreach (SPFolder oFolder in oFolders)

                        {

                           if (!oFolder.Name.Equals("Forms"))

                            {

                               

                                dr = dt.NewRow(); 

 

                                dr["Column1"] = oFolder.ItemCount.ToString();

                                dt.Rows.Add(dr);

 

                            }

                        }

 

Regards,

Sudheer


Thanks & Regards, Sudheer

Data to be copied from Document Library TO Custom List

I want to design a Visual Studio application that can copy data from a  Document Library and paste it into a Custom List. There is a Document Library with a Content Type. We want users to click a button on the SharePoint 2010 site and that will  populate a custom List with same data as document library. So I can deploy a web part.

Both Document Library and List exist and have same columns. But the VS program has to populate the List with data in Document Library. Some validation will be required such as don't put duplicate data into the list.

Any sample code will help. Can this only be done via Visual Studio?

Thanks a bunch!!!

Mayank

Site to Site REST Calls in Provider Hosted Solution

I need to read from/insert into a list that resides on one site collection from a page that lives on a different site collection.  I have tried CSOM and it's not working I think because this is a provider hosted solution.  Is it possible to use CSOM (javascript) to do this?  If not can I use REST and what if any special configuration/authentication is required.  Thanks in advance for help!

Site to Site REST Calls in Provider Hosted Solution

I need to read from/insert into a list that resides on one site collection from a page that lives on a different site collection.  I have tried CSOM and it's not working I think because this is a provider hosted solution.  Is it possible to use CSOM (javascript) to do this?  If not can I use REST and what if any special configuration/authentication is required.  Thanks in advance for help!

Check the DocumentSet is exist with the same name in a docuemnt library or not ?

Hi,

I am creating DocumentSet in timerJob and I want to validate that My Document set is exist in the Document Library or not.

please tell me the block of code to validate the Document Set is Exist or not ?

Thanks,

Deepak


Multiple File Attachment Column in Document Library (SharePoint 2013)

Hi All,

As per default, i will have only one column to attach documents in Document Library . But i need to add multiple column for documents attachment in same row.

e.g. See below column

1)Project Name    2) Attachment 1      3) Attachment 2          4)Attachment 3       5)Attachment 4     

Kindly help me for creating such column (Hope there should be any coding requirements)

Copying data from a Document Library to a Custom List - SharePoint 2010

I want to design a Visual Studio application that can copy data from a  Document Library and paste it into a Custom List. There is a Document Library with a Content Type. We want users to click a button on the SharePoint 2010 site and that will  populate a custom List with same data as document library.

Both Document Library and List exist and have same columns. But the VS program has to populate the List with data in Document Library. Some validation will be required such as don't put duplicate data into the list.

Any sample code will help. Can this only be done via Visual Studio?

Thanks a bunch!!!

Mayank

Can SharePoint Designer 2010 Workflows be attached to a different List

I have a few Approval and Reminder Workflows. They are tied to the same Document Library. Is it possible to re-attach them to a different Document Library? I don't want to design re-usable workflows. Want to stick to List Workflows.

Thanks so much!

Mayank

Adding Webpart zone dynamically

I am trying to create a tab component which bring tabs title and content from sharepoint list. In a tab content, I also want to show files from document libraray.

I am currently using SPServices to bring data of Tab Title, Content and Documents. But performance is relatively slow.

I am thinking of adding webpart zone inside tab content, so I can get documents directly instead of querying it. Is it possible to add webpart zone inside Tab Content using javascript?

Show modal dialog from C# after saving items into list

Hi,

I need to open the SP2010 modal popup(SP.UI.ModalDialog) from C# code in button click event. During this button click, i need to save some records to SP list too.

I tried btn.attributes.add. It shows the popup before saving the record itself. I cannot use "Onclientclick" as i am doing some validations using server side validators.

What could be the effective method?

 

Viewing all 11571 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>