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 6881193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:04:36+00:00 2026-05-27T05:04:36+00:00

I have a page which contains the generated content. Page.aspx: <asp:DropDownList ID=cmbUsers runat=server AutoPostBack=True

  • 0

I have a page which contains the generated content.

Page.aspx:

<asp:DropDownList ID="cmbUsers" runat="server" AutoPostBack="True" 
    oninit="cmbUsers_Init">
</asp:DropDownList>
<asp:Panel ID="pnlRights" runat="server">

Page.aspx.cs:

protected void Page_Load(object sender, EventArgs e)
{
    string [] roles = Roles.GetAllRoles();
    string sel_user = ... ; // get the user name selected by combo

    foreach (string role in roles)
    {
        CheckBox chk = new CheckBox();
        chk.Text = role;
        chk.Checked = Roles.IsUserInRole(sel_user, role);
        pnlRights.Controls.Add(chk);

    }
}
protected void cmbUsers_Init(object sender, EventArgs e)
{
            ... // fill the combo with user list

    if (!IsPostBack)
    {
        {
            cmbUsers.SelectedValue = // the current signed username;
        }
    }
}

On the first load the page is correct – all checkboxes are set as they should be (the roles where user is in are checked).
The problem happens when you change the user in combo. After change the postback is called, all checkboxes are set correctly again (saw in debugger), BUT the browser shows the checkboxes set to previous user. I do not suspect browser mistake (tried in IE, Maxthon, Mozilla), but some setting I forget to set. Is it something with caching? Could you give me some hint, please?

  • 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-27T05:04:37+00:00Added an answer on May 27, 2026 at 5:04 am

    Your rebuilding the page to a fresh state each postback. Check the IsPostBack property of the Page object to insure you only init the page once.

    protected void Page_Load(object sender, EventArgs e)
    {
        if(!Page.IsPostBack)
        {
            string [] roles = Roles.GetAllRoles();
            string sel_user = ... ; // get the user name selected by combo
    
            foreach (string role in roles)
            {
                CheckBox chk = new CheckBox();
                chk.Text = role;
                chk.Checked = Roles.IsUserInRole(sel_user, role);
                pnlRights.Controls.Add(chk);
    
            }
        }
    }
    

    Edit – Looking at your example again, this won’t work exactly, you should have a button or something that is generating the postback, and do your response logic there, not in the page_load. This is the reason your seeing this behavior though.

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

Sidebar

Related Questions

I have a page which contains a html.RenderPartial, that renders an ASP.NET MVC partial
I have a panel on an aspx page which contains an UpdatePanel. This panel
I have a child page LoginContent.aspx which contains a login form. If the user
I have an ASP.net page which contains some controls. I generate this controls by
I have a page which contains a jQuery-UI horizontal slider, created using a little
I have a web page which contains a select box. When I open a
I have built a web page which contains a Crystal Report built using the
I have a page P1 loading from site S1 which contains an iframe. That
I have an HTML page (say welcome.html) which contains an iframe to a page
I have read the page in Emacs wiki which contains a list of session

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.