Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6155355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:25:18+00:00 2026-05-23T20:25:18+00:00

I am developing a sharepoint 2007 web part that uses custom properties. Here is

  • 0

I am developing a sharepoint 2007 web part that uses custom properties. Here is one:

[Personalizable(PersonalizationScope.User), WebDisplayName("Policy Update List Name")]
[WebDescription("The name of the SharePoint List that records all the policy updates.\n Default value is Policy Updates Record.")]
public string PolicyUpdateLogName
{
    get { return _PolicyUpdateLogName == null ? "Policy Updates Record" : _PolicyUpdateLogName; }

    set { _PolicyUpdateLogName = value; }
}

The properties work fine except that the changes are not reflected in the web part until you leave the page and navigate back (or just click on the home page link). Simply refreshing the page doesn’t work, which makes me think it has something to do with PostBacks.

My current theory is that the ViewState is not loading postback data early enough for the changes to take effect. At the very least, the ViewState is involved somehow with the issue.

Thanks,
Michael

Here is more relevant code:

protected override void CreateChildControls()
{
    InitGlobalVariables();

    FetchPolicyUpdateLog_SPList();

    // This function returns true if the settings are formatted correctly
    if (CheckWebPartSettingsIntegrity())  
    {
        InitListBoxControls();

        InitLayoutTable();

        this.Controls.Add(layoutTable);

        LoadPoliciesListBox();
    }

    base.CreateChildControls();
 }

…

protected void InitGlobalVariables()
{
    this.Title = "Employee Activity Tracker for " + PolicyUpdateLogName;

    policyColumnHeader = new Literal();
    confirmedColumnHeader = new Literal();
    pendingColumnHeader = new Literal();

    employeesForPolicy = new List<SPUser>();
    confirmedEmployees = new List<SPUser>();
    pendingEmployees = new List<SPUser>();
}

…

// uses the PolicyUpdateLogName custom property to load that List from Sharepoint
private void FetchPolicyUpdateLog_SPList()
{
    site = new SPSite(siteURL);
    policyUpdateLog_SPList = site.OpenWeb().GetList("/Lists/" + PolicyUpdateLogName);
}

…

protected void InitListBoxControls()
{
    // Init ListBoxes
    policies_ListBox = new ListBox();  // This box stores the policies from the List we loaded from SharePoint
    confirmedEmployees_ListBox = new ListBox();
    pendingEmployees_ListBox = new ListBox();

    // Postback & ViewState
    policies_ListBox.AutoPostBack = true;
    policies_ListBox.SelectedIndexChanged += new EventHandler(OnSelectedPolicyChanged);
    confirmedEmployees_ListBox.EnableViewState = false;
    pendingEmployees_ListBox.EnableViewState = false;
}

…

private void LoadPoliciesListBox()
{
    foreach (SPListItem policyUpdate in policyUpdateLog_SPList.Items)
    {
        // Checking for duplicates before adding.
        bool itemExists = false;

        foreach (ListItem item in policies_ListBox.Items)

            if (item.Text.Equals(policyUpdate.Title))
            {
                itemExists = true;
                break;
            }
        if (!itemExists)
            policies_ListBox.Items.Add(new ListItem(policyUpdate.Title));
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T20:25:19+00:00Added an answer on May 23, 2026 at 8:25 pm

    Do some reading up on the Sharepoint web part life cycle. Properties are not updated until the OnPreRender event.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building a custom web part in SharePoint 2007. It needs to access specific
I'm developing a SharePoint 2010 Web Part (in C#) which needs to pull user
I am developing a custom web part for a project that I am working
I have been developing pages and web parts in SharePoint 2007/2010 for the past
I'm developing a custom webpart for SharePoint 2007 using C# and Visual Studio. I
I am developing silverlight web part for sharepoint 2010. I have an xml file
I am using sharepoint 2010 and developing a visual web part. I had javascript
Situation We are currently developing a Sharepoint 2010 site that uses Infopath 2010 forms.
I use Sharepoint 2010 and I am developing a web part where on a
I am developing silverlight web part for sharepoint 2010. In my project I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.