Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Disabled Panel control loses viewstate

Reply
Thread Tools

Disabled Panel control loses viewstate

 
 
Robert Phillips
Guest
Posts: n/a
 
      04-28-2004
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>




 
Reply With Quote
 
 
 
 
Scott Mitchell [MVP]
Guest
Posts: n/a
 
      04-28-2004
Robert, explicitly set the TextBox's in the Panel to disabled (i.e.,
Enabled = False). That is, change your server-side code to something like:

> void Page_Load(Object sender, EventArgs e)
> {
> if (Check1.Checked)
> {
> Panel1.Enabled=false;
> TestText.Enabled = false;
> TestText2.Enabled = false;
> TestText3.Enabled=false;
> }
> else
> {
> Panel1.Enabled=true;
> TestText.Enabled = true;
> TestText2.Enabled = true;
> TestText3.Enabled=true;
> }
> }


--

Scott Mitchell
http://www.velocityreviews.com/forums/(E-Mail Removed)
http://www.4GuysFromRolla.com
http://www.ASPFAQs.com
http://www.ASPMessageboard.com

* When you think ASP, think 4GuysFromRolla.com!
 
Reply With Quote
 
 
 
 
Robert Phillips
Guest
Posts: n/a
 
      04-28-2004
yep, i figured that out later. unfortunately my real form has a lot
more stuff on it. i'm going the route of looping through the panel's
controls collection.

would you consider this an asp.net deficiency?



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

 
Reply With Quote
 
Scott Mitchell [MVP]
Guest
Posts: n/a
 
      04-28-2004
Robert, I posted a much more detailed response to your problem and the
solution I proposed on my blog:
http://scottonwriting.net/sowblog/posts/1125.aspx

Happy Programming!

--

Scott Mitchell
(E-Mail Removed)
http://www.4GuysFromRolla.com
http://www.ASPFAQs.com
http://www.ASPMessageboard.com

* When you think ASP, think 4GuysFromRolla.com!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Missing Java Control Panel in START menu->Control Panel: Diff javacpl.cpl and javacpl.exe? Robin Wenger Java 0 08-18-2011 06:38 AM
Why is there no "Java Control Panel" for J2EE v5upd14 ? Reinstall Java Control Panel possible? Ulf Meinhardt Java 0 07-07-2009 08:38 AM
Serialized class in web user control loses viewstate on postback bminder@gmail.com ASP .Net 0 04-07-2006 01:09 AM
HELP: Inherited User Control Loses ViewState Spam Catcher ASP .Net 0 02-18-2006 06:41 AM
Disabled Panel control loses values Robert Phillips ASP .Net 5 04-28-2004 02:49 PM



Advertisments