R
Robert Phillips
I have a Panel control containing a few TextBox controls. The Panel is
originally enabled, I enter data into the TextBox controls. When I submit,
the Panel is disabled during the PostBack and the TextBox controls render
greyed-out, and I can see the values in the TextBox controls....this is what
I expected.
I submit again, the Panel is enabled during the PostBack. All of the
TextBox controls within the Panel are now enabled, however, the values are
gone. This doesn't happen with a TextBox control outside of the Panel that
is also enabled/disabled.
Is this by design? I have a sample below I am testing with. I have a much
more complicated form I was going to do this with.
Also, this doesn't occur when the Visible property is used.
<%@ Page Language="C#" AutoEventWireup="True" %>
<script runat="server">
void Page_Load(Object sender, EventArgs e)
{
if (Check1.Checked)
{
Panel1.Enabled=false;
TestText3.Enabled=false;
}
else
{
Panel1.Enabled=true;
TestText3.Enabled=true;
}
}
</script>
<html>
<head>
</head>
<body>
<form runat="server" ID="Form1">
<aspanel id="Panel1" runat="server" BackColor="gainsboro" Height="200px"
Width="300px">
Panel1: Here is some static content...
<asp:TextBox id="TestText" Width="100" Runat="server"></asp:TextBox>
<p/>
<asp:TextBox id="TestText2" Width="100" Runat="server"></asp:TextBox>
</aspanel>
<p/><asp:TextBox Runat="server" ID="TestText3" Width="100"/>
<p/><asp:CheckBox id="Check1" Text="Disable Panel" runat="server" />
<p/><asp:Button Text="Refresh Panel" runat="server" ID="Button1" />
</form>
</body>
</html>
originally enabled, I enter data into the TextBox controls. When I submit,
the Panel is disabled during the PostBack and the TextBox controls render
greyed-out, and I can see the values in the TextBox controls....this is what
I expected.
I submit again, the Panel is enabled during the PostBack. All of the
TextBox controls within the Panel are now enabled, however, the values are
gone. This doesn't happen with a TextBox control outside of the Panel that
is also enabled/disabled.
Is this by design? I have a sample below I am testing with. I have a much
more complicated form I was going to do this with.
Also, this doesn't occur when the Visible property is used.
<%@ Page Language="C#" AutoEventWireup="True" %>
<script runat="server">
void Page_Load(Object sender, EventArgs e)
{
if (Check1.Checked)
{
Panel1.Enabled=false;
TestText3.Enabled=false;
}
else
{
Panel1.Enabled=true;
TestText3.Enabled=true;
}
}
</script>
<html>
<head>
</head>
<body>
<form runat="server" ID="Form1">
<aspanel id="Panel1" runat="server" BackColor="gainsboro" Height="200px"
Width="300px">
Panel1: Here is some static content...
<asp:TextBox id="TestText" Width="100" Runat="server"></asp:TextBox>
<p/>
<asp:TextBox id="TestText2" Width="100" Runat="server"></asp:TextBox>
</aspanel>
<p/><asp:TextBox Runat="server" ID="TestText3" Width="100"/>
<p/><asp:CheckBox id="Check1" Text="Disable Panel" runat="server" />
<p/><asp:Button Text="Refresh Panel" runat="server" ID="Button1" />
</form>
</body>
</html>