473,770 Members | 1,645 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Disabled Panel control loses values

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....thi s 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(Objec t sender, EventArgs e)
{
if (Check1.Checked )
{
Panel1.Enabled= false;
TestText3.Enabl ed=false;
}
else
{
Panel1.Enabled= true;
TestText3.Enabl ed=true;
}
}
</script>

<html>
<head>
</head>
<body>

<form runat="server" ID="Form1">

<asp:Panel id="Panel1" runat="server" BackColor="gain sboro" 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>
</asp:Panel>

<p/><asp:TextBox Runat="server" ID="TestText3" Width="100"/>

<p/><asp:CheckBo x id="Check1" Text="Disable Panel" runat="server" />
<p/><asp:Button Text="Refresh Panel" runat="server" ID="Button1" />

</form>

</body>
</html>
Nov 18 '05 #1
5 6934

Robert,

Are you posting back as a result of checking Check1?

If so you might not have the correct value for Check1
during Page_Load -- you would want to enable/disable controls in the
Check1 event that triggers the post back.

Jim
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #2
Hi, Robert Phillips,

The cause for the behavior is the browser not posting the values in the
<input type=text disabled> controls. You can try enabling these on the
client side in the onsubmit event or, alternatively, preserve the values on
the server-side (in the Session or in the ViewState maybe) before you set
Enable = false.

Hope this helps
Martin
"Robert Phillips" <ph************ *@myfloridahous e.com> wrote in message
news:u4******** *****@TK2MSFTNG P11.phx.gbl...
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....thi s 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(Objec t sender, EventArgs e)
{
if (Check1.Checked )
{
Panel1.Enabled= false;
TestText3.Enabl ed=false;
}
else
{
Panel1.Enabled= true;
TestText3.Enabl ed=true;
}
}
</script>

<html>
<head>
</head>
<body>

<form runat="server" ID="Form1">

<asp:Panel id="Panel1" runat="server" BackColor="gain sboro" 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>
</asp:Panel>

<p/><asp:TextBox Runat="server" ID="TestText3" Width="100"/>

<p/><asp:CheckBo x id="Check1" Text="Disable Panel" runat="server" />
<p/><asp:Button Text="Refresh Panel" runat="server" ID="Button1" />

</form>

</body>
</html>


Nov 18 '05 #3
I do somthing like that with tables when I hide and show rows. An important thing to remember is that at the end of the Asp.NET rainbow you still come down to HTML markup. If the browser doesent paint it, it doesnt exist anymore to the client or the postback event UNLESS you stuff those values in some kind of server or local storage like cookies, or sessions, or state server. What I do, if your not on a cluster, is when an event is fired that removes a parent control from the presentation, stuff the values into session lik

public void HidePanel(

Session["saveChildContr ol1"] = objChildControl 1.Text; // assuming it's a textbo
Session["saveChildContr ol2"] = objChildControl 2.Text
Session["hasSaveControl s"] = "true"
objPanel.Visibl e = false

then to reload i

public void ShowPanel(

objPanel.Visibl e = true;
// remember to check if it was hidden as you will bomb on referencing non existant stuf
if (Session["hasSavedContro ls"] != null

objChildControl 1.Text = Session["saveChildContr ol1"].Text.ToString( )
objChildControl 2.Text = Session["saveChildContr ol2"].Text.ToString( )

}
Nov 18 '05 #4
i know what you're saying, but if you look at the html generated in my
sample, all of the controls are being generated, but it's intersting that
the div (for the panel) is set to disabled, but the contained TextBox
controls are not (the TextBox control outside the panel does have its html
disabled property set).

the disabled TextBox that isn't in the panel maintains its value fine,
whether or not it is in the posted data.

so, its like asp.net isn't painting it correctly...thu s it see it as enabled
during the postback, but no value is avialable in the posted data.

"Harold" <an*******@disc ussions.microso ft.com> wrote in message
news:14******** *************** ***********@mic rosoft.com...
I do somthing like that with tables when I hide and show rows. An important thing to remember is that at the end of the Asp.NET rainbow you
still come down to HTML markup. If the browser doesent paint it, it doesnt
exist anymore to the client or the postback event UNLESS you stuff those
values in some kind of server or local storage like cookies, or sessions, or
state server. What I do, if your not on a cluster, is when an event is fired
that removes a parent control from the presentation, stuff the values into
session like
public void HidePanel()
{
Session["saveChildContr ol1"] = objChildControl 1.Text; // assuming it's a textbox Session["saveChildContr ol2"] = objChildControl 2.Text;
Session["hasSaveControl s"] = "true";
objPanel.Visibl e = false;

}

then to reload it

public void ShowPanel()
{
objPanel.Visibl e = true;
// remember to check if it was hidden as you will bomb on referencing non existant stuff if (Session["hasSavedContro ls"] != null)
{
objChildControl 1.Text = Session["saveChildContr ol1"].Text.ToString( ); objChildControl 2.Text = Session["saveChildContr ol2"].Text.ToString( ); }
}

Nov 18 '05 #5
Hi, Harold,

The problem is with Enabled = {true | false} for the container control.

When you set Visible = {true | false} the child controls keep their values,
so there is no need for this overhead.

Greetings
Martin
"Harold" <an*******@disc ussions.microso ft.com> wrote in message
news:14******** *************** ***********@mic rosoft.com...
I do somthing like that with tables when I hide and show rows. An important thing to remember is that at the end of the Asp.NET rainbow you
still come down to HTML markup. If the browser doesent paint it, it doesnt
exist anymore to the client or the postback event UNLESS you stuff those
values in some kind of server or local storage like cookies, or sessions, or
state server. What I do, if your not on a cluster, is when an event is fired
that removes a parent control from the presentation, stuff the values into
session like
public void HidePanel()
{
Session["saveChildContr ol1"] = objChildControl 1.Text; // assuming it's a textbox Session["saveChildContr ol2"] = objChildControl 2.Text;
Session["hasSaveControl s"] = "true";
objPanel.Visibl e = false;

}

then to reload it

public void ShowPanel()
{
objPanel.Visibl e = true;
// remember to check if it was hidden as you will bomb on referencing non existant stuff if (Session["hasSavedContro ls"] != null)
{
objChildControl 1.Text = Session["saveChildContr ol1"].Text.ToString( ); objChildControl 2.Text = Session["saveChildContr ol2"].Text.ToString( ); }
}


Nov 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
10844
by: Fabrizio | last post by:
Hi, There is any chance to insert a control like a text box in a panel choosing the absolute position? When I try to insert a label , the panel positions the control on a locked position. Thanks Fabrizio
0
1658
by: Niraj via DotNetMonster.com | last post by:
i had put a panel in form and text box,label and numericupdown control in it. Now i had use to send the form as me to some function byref then again from that particular function i use to send the me as f to another function to check some text box which are in pane control. now when i try to check the values of text box if i had edited i dont get any of the edited value to check bt i always get old values of textbox which are in panel....
2
3500
by: James T. | last post by:
Hello! I developed a composite control that inherits from HyperLink and overrides Render method. In web form I am using this control with DataGrid. On DataGrid ItemDataBound event I set ImageWidth and ImageHeight values programmatically. But on post-back the control loses ImageWidth and ImageHeight values. What I am doing wrong?
9
3187
by: Bill Long | last post by:
I have a control that simply displays a list of links. Following one of the links doesn't post back or redirect to another page, it simply hides the current panel and shows the one you selected... So the behavour is similar to a tab control. The user is expected to fill out required data on each of the panels before pressing a submit button which is visible from all panels. Problem I have is validating the data entered by the user. I...
1
2295
by: Israel | last post by:
The problem: I want to know, definitively when a slider loses focus after a user has started sliding and hasn't released the mouse yet. It appears that this is captured with the WM_ACTIVATEAPP message but this only goes to the form and I want it in the user control that maybe very much removed from the form's knowledge; i.e. the form may launch a 3rd party form that, upon a call back, decides to launch other form that has my user control...
3
3506
by: Yoavo | last post by:
Hi, I have a ListView control and I make it disabled when a certain event occur. My problem is that when the control become disabled, the selection on the selected item is gone. (I want that the user will still be able to see the selected item). Yoav.
8
5370
by: =?Utf-8?B?R3JlZyBMYXJzZW4=?= | last post by:
I'm trying to figure out how to modify a panel (panel1) from a backgroundworker thread. But can't get the panel to show the new controls added by the backgroundwork task. Here is my code. In this code there is a panel panel1, that I populate with a lable in the foreground. Then when I click on "button1" a backgroundworker thread in async mode is started. When the backgoundworker thread completes the thread returns a panel to populate...
11
11270
by: dongarbage | last post by:
Hi there, I'm very much a C# novice. How do you do freehand drawing on a panel with a mouse in c#? Thanks, Don
17
10351
by: govolsbaby | last post by:
Is there a way to leave the button forecolor unchanged when it is disabled? I have multiple buttons on the form and depending on various user inputs, some will or will not be enabled but I'd rather their text not go to gray. Thanks.
0
9595
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9873
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7420
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6682
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5313
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5454
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3974
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3578
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2822
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.