I have a web panel full of buttons. I want the panel to not be visible at first. But while it's invisible, I want to set certain buttons to visible/invisible and enabled/not enabled.

Then, when I make the panel visible, I want my buttons to have the attributes I set above.

But I'm finding that when I attempt to set buttons to visible while the panel is not visible , the buttons' visible property is not actually getting set.

Is there a way around this?

Thanks,
Randy

Hi,
Can you provide some more details as I am not able to recreate the problem.
I tried the following code and it seems to work fine

.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Pannel : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void BtnSet_Click(object sender, EventArgs e)
    {
        p1.Visible = false;
        Button1.Visible = true;
        Button2.Visible = false;
        Button3.Visible = true;
        Button4.Enabled = false;
        Button5.Enabled = true;
    }

    protected void btnVisible_Click(object sender, EventArgs e)
    {
        p1.Visible = true;
    }
}


.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Pannel.aspx.cs" Inherits="Pannel" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
    <asp:Panel ID="p1" runat="server" BackColor="#FFC0C0" BorderColor="Red" BorderStyle="Solid" BorderWidth="1px" Direction="LeftToRight" Height="227px" Visible="False" Width="820px">
        <asp:Button ID="Button1" runat="server" Text="B1" /><br />
        <asp:Button ID="Button2" runat="server" Text="B2" /><br />
        <asp:Button ID="Button3" runat="server" Text="B3" /><br />
        <asp:Button ID="Button4" runat="server" Text="B4" /><br />
        <asp:Button ID="Button5" runat="server" Text="B5" /></asp:Panel>
        <asp:Panel ID="Panel2" runat="server">
        </asp:Panel>
        <asp:Button ID="BtnSet" runat="server" OnClick="BtnSet_Click" Text="Set options" />
        <asp:Button ID="btnVisible" runat="server" OnClick="btnVisible_Click" Text="Make Panel Visible" /></div>
    </form>
</body>
</html>

P.K.' Thanks for the response. I'm sorry I'm responding so late.

There's a lot of code, but basically the problem is that the buttons are located on a panel. When the panel is not visible, I can't set any buttons as visible. It doesn't complain, but it doesn't change them.

When the panel is visible, I can set the buttons on and off, of course. If I then make the panel invisible, it does not change the buttons' visibility properties.

hi,

why you set panel to visible or not instead set the buttons to visible or invisible.In both ways you can achieve the same functionality.i can help more if you post your code here.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.