Link to home
Start Free TrialLog in
Avatar of Dovberman
DovbermanFlag for United States of America

asked on

How to set the table cell visible property in code.

I set the visible property of a table cell to false.

I can set the property to true in the Page_Load procedure.

The property is not set in any other procedure.

ASPX file
=======
<asp:TableCell ID="celMenu"  Visible="False">

Code Behind

protected void Page_Load(object sender, EventArgs e)
        {
            celMenu.Visible = true;  // celMenu becomes visible
            if (!IsPostBack)
            {
                StockProLogin.Focus();
                //mnuScoreStocks.Visible = false;
                celMenu.Visible = true;   // celMenu becomes visible
               
            }
        }


            if (currentUser != null) // User is in database
            // Determine user status
            {

                // Verify registration status
                strUserName = currentUser.UserName;
                strUserID = currentUser.ProviderUserKey.ToString();
                e.Authenticated = (strUserName == "dovberman");
 
                if (e.Authenticated==true)
                {
                    strUserName = StockProLogin.UserName;
                    strUserID = currentUser.ProviderUserKey.ToString();
                    string strLoginText = "Hi " + StockProLogin.UserName + " You are logged in";
                    lblLoginMsg.Text = strLoginText;
                    // lblLoginMsg. Text displays as expected.
                    celMenu.Visible = true;  // celMenu does not become visible
                }

                else // User is not in database
                {
                    e.Authenticated = false;
                    StockProLogin.FailureText = StockProLogin.UserName + ". You were not found. Re-enter User Name and or Password.";
// StockProLogin.FailureText  displays as expected.
                    celMenu.Visible = false;
                }
                            }

Please help.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Miguel Oz
Miguel Oz
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dovberman

ASKER

I resolved this by using the page_load event.

Page_Load

If Admin not logged in
    Display message for Admin to log in and select the page again from the site.menu.

If Admin logged in
     Open the page and display the table cell that contains the menu.

aspx:

    <asp:Table ID="Table1" runat="server" Height="2.52in" Width="284px">
       <asp:TableRow>
               
           <asp:TableCell ID="celMenu"  Visible="False" >
                <ul>
                    <li><a id="mnuHiPerf" runat="server" href="~/Admin/FindPriceExceptions.aspx">High Performers</a></li>
                    <li><a id="mnuWatchList" runat="server" href="~/Admin/WatchListNew.aspx" >Manage Watch List</a></li>
                    <li><a id="mnuScoreStocks" runat="server" href="~/Contact" >Score Stocks</a></li>

Page_Load

             if (User.Identity.IsAuthenticated)
                {
                    strUserName = User.Identity.Name;
                    strUserID = currentUser.ProviderUserKey.ToString();
                    if (strUserName == "AdminName")
                    {
                        celMenu.Visible = true;  // Menu is now visible
                    }

                    conStockSelect.Close();
                }
                else
                {
                    strUserName = "Guest";
                }
                // End If user authenticated
I appreciate your interest. Meanwhile, I resolved it.  See my previous post.