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

Top 5 Contributors of the Month
Imran Ghani
Sohaib Khalid
Post New Web Links

Update Webpart Assembly info programmatically

Posted By:      Posted Date: April 10, 2011    Points: 0   Category :C#


We have a requirement where in we need to update all the old custom webpart which are added to the portal with new Assembly information. The way we have planned is to create a console app, iterate through all the Pages Library withing each Site and Sub-site, get the WebPart Collection and once the "SPWebpartCollection" object is created, use System.Reflection.PropertyInfo and get all the property. I am done almost uptill here, but now stuck on how to proceed further. I would like to change the WebPart Assembly and Namespace information. The reason why this is required is, earlier earlier each webparts were having different dll. Now we have clubed all the webpart under one Assembly and the namespace are kept same now. But because the webpart were added to the page manually, they are holding the reference to the old assembly. The other way would be to remove the webpart and re-add the webpart which is not very much accepted when the number of sites and sub-sites involved in more than 1500.

Any solution would be really appreciated. Thanks.

Regards, Paddy

View Complete Post

More Related Resource Links

Trying to set update panel trigger programmatically


 I have a recursive sub that finds a dropdown list and sets up an AsyncPostbackTrigger for an update panel. I have tried calling this sub both from page_init and page_load 

If the dropdownlist is within the update panel, eveything works fine. If the dropdown list is not in the updatepanel I get error

A control with ID 'ddlPersonFilter' could not be found for the trigger in UpdatePanel 'up1'. In both cases the sub does find the dropdown list and executes the code to set up the trigger. Thanks for your help.

    Private Sub SetUpdatePanelTrigger(ByVal oControl As Control)
        For Each ctrl As Control In oControl.Controls
            If TypeOf ctrl Is DropDownList Then
                If CType(ctrl, DropDownList).ID = "ddlPersonFilter" Then
                    Dim thisddl As New DropDownList
                    Dim thistrigger As New AsyncPostBackTrigger
                    thisddl = ctrl
                    thistrigger.EventName = "SelectedIndexChanged"
                    thistrigger.ControlID = thisddl.ID
                    Exit Sub
                End If
                If ctrl.HasControls Then
                End If
            End If

Programmatically delete a .webpart file from wpcatalogs folder from an IIS website


We are using a third party wsp in our solution which directly adds the web parts into the web application store rather than the web part gallery(References to them are present in IIS site's wpcatalog directory). We want to remove these web part files so that the users will not be able to add these web parts to pages directly. Or any other modification so that users will not be able to add these directly. Is there a way we can do this programmatically?

How to update row using Domain Service Class programmatically?

How to update row using Domain Service Class programmatically in Silverlight without bind to any datagrid and other control? Please help.chanmm

How to update row using Domain Service Class programmatically?

How to update row using Domain Service Class programmatically in silverlight without binding to any datagrid and so? Please help.  chanmm

Add webpart programmatically to page in sharepoint

Hi How to add webpart programmaticaly in sharepoint ? CheersMomo

Error when programmatically connect filter webpart with excel webpart

Hello, On MOSS 2007 SP2 64bit I am trying to programmatically connect a SPSlicerTextWebPart with an ExcelWebRenderer but I am getting the error: "The connection point "IFilterValues" on "g_046273fe_af27_4064_86b1_70f2c57c326c"(the excel webpart)   is disabled" and I can't find a way to enable it... I'm using the folowing code: using(SPLimitedWebPartManager webPartMgr = web.GetLimitedWebPartManager("Stats.aspx", PersonalizationScope.Shared)) { Microsoft.SharePoint.Portal.WebControls.SPSlicerTextWebPart filterWebPart = (Microsoft.SharePoint.Portal.WebControls.SPSlicerTextWebPart)webPartMgr.WebParts[0]; if (filterWebPart.ConnectionID == Guid.Empty) { filterWebPart.ConnectionID = Guid.NewGuid(); } webPartMgr.SaveChanges(filterWebPart); ProviderConnectionPoint providerCP = webPartMgr.GetProviderConnectionPoints(filterWebPart)[0]; Microsoft.Office.Excel.WebUI.ExcelWebRenderer excelWebPart = (Microsoft.Office.Excel.WebUI.ExcelWebRenderer)webPartMgr.WebParts[1]; if (excelWebPart.ConnectionID == Guid.Empty) { excelWebPart.ConnectionID = Guid.NewGuid(); } excelWebPart.AllowConnect = true; webPartMgr.SaveChanges(excelWebPart); ConsumerConnectionPoint consumerCP = webPartMgr.GetConsumerConnectionPoints(excelWebPart)[2]; TransformableFilterValuesToFilterValuesTransformer t = new TransformableFilterValue

.NET COM Exposed Assembly Interface update

Hi, I am trying to extend a COM Class I wrote some time ago. Following the instructions I found in this post by Heath Stewart http://blogs.msdn.com/b/heaths/archive/2005/03/09/391358.aspx I have create a New interface INetList01 :  INetList that inherist from my original one INetList, and I have added few methods. Then I have changed the Class so that instead of Class : INetList will do Class: INetList01 The problem is that now in COM I can only see the only method I have added to INetList01 and not all of them (the one coming from INetList) Is that the right way to follow to update COM components without breaking with the old code? Thanks Here you can find the code.   [Guid("b7268589-97e3-4189-9687-54298ddbb3a4"),  ComVisible(true)]     public interface INetList : System.Collections.IEnumerable     {         [DispId(-4)] //Enumerator         new IEnumerator GetEnumerator();                [DispId(0)]  //Default Property         object this[int index] { get; set; }         [DispId(3)]         int Count { get; }         [DispId(4)]   &nbs

Change webpart properties programmatically

I am attempting to modify the properties of another webpart when my webpart's button is clicked. The code compiles and runs, and stepping through it shows that the properties do change. However, they don't stay changed. This example attempts to toggle the visibility state, but other properties won't stay changed either. Any help is appreciated.     SPSecurity.RunWithElevatedPrivileges(delegate() { // get the site in this context using (SPSite SiteCollection = new SPSite(mySiteGuid)) { // get the web in this context SPWeb myWeb = SiteCollection.OpenWeb(myWebGuid); myWeb .AllowUnsafeUpdates = true; // Hide/display another webpart. Microsoft.SharePoint.WebPartPages.SPLimitedWebPartManager mgr = null; mgr = myWeb.GetLimitedWebPartManager( "default.aspx", System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared); foreach (System.Web.UI.WebControls.WebParts.WebPart myWebPart in mgr.WebParts) { // If this is the webpart we want to modify... if (myWebPart.Title == "Other Webpart Name") { // Toggle the visibility state. myWebPart.Visible = ! myWebPart.Visible; myWeb.Update(); break; } } } });

How to update the "ListView.SelectedListViewItemCollection" programmatically in C# ?

How to modify the contents of "ListView.SelectedListViewItemCollection" programmatically ? Mouse clicks in a ListView are recorder in this collection. Can I access to the collection programmatically ? If YES, please provide me with some code samples. ListView.SelectedListViewItemCollection selectedItems = this.listViewFile.SelectedItems; Thanks

Help with programmatically set Edit, Update in Gridview


 I'm at the front end of allowing the user to update their data that requires nested gridviews.

I thought I had it set up correctly, but; once I have the grivdiew in Edit mode, when I move the cursor to the first row's textbox, the routine switched out of Edit mode (without a clicking on the Update). I would like to update the data on the screen before the program decides to update the db.

What's causing this?

Here's my aspx page as follows:

<%@ Page Language="VB" AutoEventWireup="false" EnableEventValidation="false" CodeFile="RONs_UPDATING.aspx.vb" Inherits="RONs_UPDATING" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
    <form id="form1" runat="server">
    <div id="div_units" runat="server" style="font-size: medium">
        <asp:GridView ID="gv_x_Units" runat="server" AutoGenerateColumns="False" Style="z-index: 100; left: 110px; position: absolute; top: 10p

Hide an webpart whit no active info


Is it possible to hide a webpart that has no active content and when there is an active entry, make it visible again?


WebPart Assembly deployed to GAC is not working


I've developed a web part using WSPBuilder and created a feature to deploy it

I managed to get the web part running on my web application using WSS_Minimal trust level in Web.Config, so there is no problem with the code (Anyway I'm adding a literal control with a fixed text in CreateChildControls()).

I knew that deploying to GAC does not require setting the trust level as the assembly deployed to GAC is fully trusted by CLR but when I change the trust level to any of (Minimal/Low/Medium/High) while deploying to GAC, I get the exception

"Security Exception
Description: The application attempted to perform an operation not allowed by the security policy.  To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

Exception Details: System.Security.SecurityException: Request for the permission of type 'Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint.Security, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c' failed"

so why I'm getting this exception when deploying to GAC while the assembly deployed should be FULLY trusted and not requiring a specific trust level as opposed to \BIN deployment.

THosE wHo doN'T apPreCiATe LiFe,

Update User Profile info from another SharePoint site


Hi All,

I have MOSS 2007 up and running, and the Staff Profile is maintained by the users.

Now there is another NEW sharepoint 2010 apps planning. In order to avoid the duplication of staff profile in SharePoint 2010, the requirement is to update the SharePoint 2010 Staff Profile from the existing MOSS 2007.

Is it possible? Any help.


Get Assembly info of my current C# Application


Hello, developers...

How can i get the assembly information of my current C# application, for example its GUID?



Amin Mashayekhi

Update a Choice column(Check box) programmatically



in Document library, i have one column, type- choice , diplay using Check boxs for multiple select.

When i update the field programmatically, it is not working , if i selected more than one choice, otherwise it is working.

Meaning: When more than one choice is selected. it is updated without any error and also shown in allitems.aspx page, but while editing properties of the item, the choices are not checked if more than one choice is selected.

how to update the filed with multiple select? please guide me. Thanks in advance.

Adding webpart programmatically



i am adding an webpart programmatically on an button click event but it is not visible in the webpart zone on first click , if i click the button again it will become visible. and page is in edit mode when i am clicking the button.

Any body help out in this issue.




Custom WebPart update


Ok long story short, we had an outside dev create some custom webparts and other items for our system.  This all works fine.

Now we need to make a small change, re-word a check box on a form.  I have the source code and can make the change from vs2008. 

Now how to I get my change into our server?  All the build does in VS is create a new dll file.  I don't know what to do from here.  I tried to replace the dll in the bin direcotry and recyled the app pool but nothing changed.

I have googled all i can come up with and there are a few items talking about manual install of dll files nothing to replacing an already installed webpart.

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