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

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Custom web part properties are not saved in SharePoint 2010 visual web part

Posted By:      Posted Date: October 11, 2010    Points: 0   Category :SharePoint

I have created my first visual web part in SP2010.  In 2007 version I didn't use user controls so all of my code was in a single file for the most part.  Now I've separated out the code.  Everything works great and I like this a lot better (more like traditional ASP.NET development) with one exception.  In my bootstrap .cs file (I call it that because it does nothing but load the user control file) I put all of my custom web part properties.  Then in my web part code-behind I reference them thru an instance of the containing class.  I must have something incorrectly configured because none of the changes to the properties at runtime are getting updated in the code.  Here's a filtered view of how I have it wired together:

Sample property in the top level .cs file:

private string m_ImagePath = "sites/myapp/images1/branded_image.png";
   WebDisplayName("Relative path to header image"),
   WebDescription("Relative path to header image"),

View Complete Post

More Related Resource Links

Sharepoint 2010 power tools visual sandboxed web part issue!!


Hi guys

I tried to use a simple hello world web part with with sharepoint power tools the solution is added ok but when I try to add the web part to the page I get this error "Unable to load assembly group. The user assembly group provider...." Any thoughts






Using Web Service in SharePoint 2010 Standard Web part using Visual Studio 2010

Hi All,               Have an issue with  Web service in calling  by SharePoint 2010 Standard Web part using Visual Studio 2010. If you can tell where I went wrong or tips to solve this would be great for me. What I have done is like this.. 1) Created new 'Empty SharePoint' project : as Farm solution 2) Added Web parts 3) Trying to add Web Service : There was no option for adding Web Service , so added as 'Add new Service' , this created entries in app.config file 4) ServiceName : shown as name space  (what  I'm  expecting is as Global  object with all methods ) 5) Created Object of namespace.ServiceName.ServiceSoapClient and tried to call one of it's method 6) Build and deployed 7) While viewing that web part it is showing an error as [InvalidOperationException: Could not find default endpoint element that references contract 'SerialKeyService.ServiceSoap' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.]         Error in detail : [TargetInvocationException: Exception has been thrown by the target of an invocation.]   at System.RuntimeTypeHandle.CreateInstance(RuntimeType t

Sharepoint 2010 Visual Web Part - Personalizable


I have a visual web part which has 2 public properties

One is webbrowsable and the other is not.

I can retreive the data from the properties into the usercontrol and display them, but i'm unable to update the value and store it against the webpart, just as i would from the editor section.


Here are my 2 public properties.

 <Personalizable(), WebBrowsable()> _

    Public Property myString() As [String]


            Return m_myString

        End Get

        Set(ByVal value As [String])

            m_myString = value

        End Set

    End Property

    Private m_myString As [String]



    <Personalizable(PersonalizationScope.Shared)> _

    Public Property myStoreage() As [String]


            Return m_myStorage

        End Get

        Set(ByVal value As [String])


Consuming SharePoint 2010 Web Analytics Service in a Custom Web Part



I am writing a custom webpart to show up the Top Queries. As per my understanding we would need to use the Web Analytics WCF Service/Proxy in our custom Web Part code and try and access the method that returns the Top Queries.

Please let me know the name of the Web Analytics WCF Service/Proxy to be used and the if you can get me the method. I have been trying to search for the name of the Web Analytics Web Service/Proxy, but in vain. Looks document is at scarse.

Appreciate your help here.




visual web part in sharepoint 2010



I have created a visual web part in visual studio 2010 and i can deploy it directly to my local site but i was wondering that how do create a wsp out of the project and hand it over to sharepoint admin..i don't see and wsp option over there ...do i need to install some additional thing..please can someone help me out with this.



Content Query Web Part missing in SharePoint 2010

If you don't see content query web part listed in the web parts list, this is because you have not enabled "Search Server Web Parts" feature in site collection features. Enable this feature and content query web part will show in the list of web parts.

Creating a SharePoint 2010 Web Part That Can Read and Write Data to an External Data Source

Learn to use Visual Studio 2010 to create a Visual Web Part that uses a BCS external content type in SharePoint Server 2010 to read and write data to the AdventureWorks sample database.

Sample: Creating a SharePoint 2010 Web Part That Can Read and Write Data to an External Data Source

Explore the code in this visual how-to article as you learn to use Visual Studio 2010 to create a Visual Web Part that uses a BCS external content type in SharePoint Server 2010.

Quick Note: Accessing Data in a SharePoint 2010 Web Part by using LINQ

In this exercise, you develop and deploy a visual Web Part that reads data from two lists by using a LINQ query and displays it in a DataGrid control.

Creating Custom SharePoint 2010 Field Types and Controls with Visual Studio 2010 and Silverlight 3

Learn how developers can create rich experiences in SharePoint Server 2010 publishing sites using Microsoft Silverlight 3.

Video: Creating Custom SharePoint 2010 Field Types and Controls with Visual Studio 2010 and Silverli

Watch the video that accompanies the MSDN article and learn how developers can create rich experiences in SharePoint Server 2010 publishing sites using Microsoft Silverlight 3.

Module 3: Building Blocks for Web Part Development in SharePoint 2010

The SharePoint platform includes many built-in Web Parts that you can include in your solution, and provides many more components that you can use in Web Parts that you develop.

Overriding web.config in sharepoint webpart/using custom membership in web part

I'm developing a web part for MOSS 2007. The web part is being deployed to a web application which utilizes forms-based authentication, and role/membership providers to control users. The membership table has been edited to include addition user info (I am aware, that this isn't the best way to handle additional user, i.e. profiles etc., however, this is a requirement from another department). Since my web part needs to access this information, I was thinking of implementing a custom membership provider. So far I've followed: http://msdn.microsoft.com/en-us/library/6tc47t75.aspx and I've got my custom membership class, and a very stripped down membershipprovider-class. But how do I enable/use this membership provider in my web part? I've tried creating a simple web.config in the "WebPartCode" folder of my solution, next to my webpart code file, with connection string and membership provider tags. But I don't even really know how to build/reference/use the membership provider itself, so I don't know what else I need to do. I've built a C# class library project with the two classes (membershipprovider and custom membershipuser) and compiled it and installed it in the global assembly cache - is this correct? and how do I access them from here? Hope someone can help

Sharepoint 2010 - RSS Viewer Web Part has some AJAX issues

Hi, I've this problem in RSS Viewer. If you select the "Enable Asynchronous Automatic Refresh?" checkbox, the Web Part will not render properly, but will give an error: "An unexpected error occured while rendering the webpart." Anybody ever had this problem? Tks,

How do I change the backlground and font color of a web part header - Sharepoint 2010

Hello,  Im verya mateur with Sharepoint so bare with me.   We are running Sharepoint 2010 and I am settingup a basic site for our company.  What I need to know is there a way to change the color of the web part header.   I have a calendar web part that displays a list of our holidays, and I was able to change the background color of the content as well as the font colors for the list of holidays,  but I cannot seem to change the background for the title box where it says Holidays and Events remains with a white background.   I would appreciate any help!   Thanks   Charlie   charlieprice@live.com

How to Fire events on SharePoint DateTime Control in visual web part

Hi All, I am working on visual webpart of SharePoint 2010. I am using a <SharePoint:DateTimeControl> i m trying  to fire OnDateChanged event on it. I am not getting the Appropriate way to create the event. please help me out!!!!   void ToDate_OnDateChanged(object sender, EventArgs e)         {                         if (ToDate != null)             {                 DateTime min = Convert.ToDateTime(FromDate.SelectedDate.ToString());                 DateTime max = Convert.ToDateTime(ToDate.SelectedDate.ToString());                 int noofdays = Convert.ToInt32((max - min).TotalDays);                 txtNoOfDays.Text = noofdays.ToString();             }         }    <SharePoint:DateTimeControl runat="server" Calendar="Gregorian"  

Custom Web Part Problem After SharePoint Restore

Hi, I've recently moved our sharepoint site and databases (using Microsoft Internal Database) to another standalone server. I did a catastrophic backup and then restored it on the destination server successfully via the central Administration page. I have also copied our custom web part library dll to 'c:\windows\assembly' directory and 'C:\Inetpub\wwwroot\wss\VirtualDirectories\80\bin' directory. I also copied over the old web.config file to 'C:\Inetpub\wwwroot\wss\VirtualDirectories\80'. However, I still seem to be missing something as I get the error below while loading the site. I haven't been able to find a solution so hoping someone has seen it before here. Has anyone seen this happen before? Any advice/help would be greatly appreciated. Many thanks. Mehds ERROR====================================================================================================== The “webpartname” web part appears to be causing a problem. Object reference not set to an instance of an object.  Web parts maintenance page: if you have permission, you can use this page to temporarily close web parts or remove personal settings. For more information, contact you site administrator. ==========================================================================================================
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