OnPreRender method does not change control state during postback
<p>I have a MasterPage "EditMaster" with a UserControl "CtrlStatus". CtrlStatus simply checks if a specific value is set in a Session. If it is, then it shows it's content, else it stays hidden.</p>

<p>Next I have a Page which prepares table with values and several Buttons in the code-behind (dynamically), based on a variable I pass when accessing the Page. Each Button gets it's Command/OnClick (tried it with both) event linked to a handler.</p>

<p>After the postback, in the handler I save the needed value in the Session. Which should ensure that the content of CtrlStatus will be shown and in the best case scenario, it should be visible on the result of the postback already -> that's why I check the Session value (CtrlStatus) in "OnPreRender" overriden method.</p>

<p>But I can't seem to get the content to show on the result of the postback. The content is shown only after refresh/redirect.</p>

<p>CtrlStatus does NOT have any updatePanel, which to my knowledge might be the underlying problem. But even if it had, I don't know how to call update() on it from the OnClick handler. And if I debug the whole process, the condition in CtrlStatus is evaluated correctly and visibility is set to true.</p>

<p>How do I force the UserControl to display it's content ?</p>

<p>1/ Handler for the dynamically generated control (in Page)</p>

<pre><code>private void handleGeneratedBtn(object sender, EventArgs e)
        {
            LinkButton btn = (LinkButton)sender;
            if (btn.CommandName == "UserID")
            {
                Guid userId;
                if (Guid.TryParse(btn.CommandArgument, out userId))
                {
                    setSessionVariable(userId);
                    updatePanel1.Update();
                }
            }
        }
</code></pre>

<p>2/ Generation of the Button (in Page)</p>

<pre><code>            int counter = 0;
            foreach (var userID in listUsers)
            {
                TableRow row = new TableRow();

                LinkButton b = new LinkButton();
                b.ID = "Btn_User_" + counter++;
                b.CommandArgument = userID ;
                b.CommandName = "UserID";
                b.Command += handleGeneratedBtn;
                TableCell c = new TableCell();
                c.Controls.Add(b);
                row.Cells.Add(c);
                rows.Add(row);
            }
</code></pre>

<p>3/ OnPreRedner method of the CtrlStatus (UserControl that exists in MasterPage)</p>

<pre><code>protected override void OnPreRender(EventArgs e)
    {
        var value = getSessionVariable();

        if (value != null)
        {
            if (value == "something")
            {
                showContent();
            }
            else
            {
                hideContent();
            }
        }
        base.OnPreRender(e);
    }
</code></pre>