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">
<asp:Panel 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>
</asp:Panel>
<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> 5 6910
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!
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*************@myfloridahouse.com> wrote in message
news:u4*************@TK2MSFTNGP11.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....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">
<asp:Panel 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> </asp:Panel>
<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>
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["saveChildControl1"] = objChildControl1.Text; // assuming it's a textbo
Session["saveChildControl2"] = objChildControl2.Text
Session["hasSaveControls"] = "true"
objPanel.Visible = false
then to reload i
public void ShowPanel(
objPanel.Visible = true;
// remember to check if it was hidden as you will bomb on referencing non existant stuf
if (Session["hasSavedControls"] != null
objChildControl1.Text = Session["saveChildControl1"].Text.ToString()
objChildControl2.Text = Session["saveChildControl2"].Text.ToString()
}
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...thus it see it as enabled
during the postback, but no value is avialable in the posted data.
"Harold" <an*******@discussions.microsoft.com> wrote in message
news:14**********************************@microsof t.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["saveChildControl1"] = objChildControl1.Text; // assuming it's a
textbox Session["saveChildControl2"] = objChildControl2.Text; Session["hasSaveControls"] = "true"; objPanel.Visible = false;
}
then to reload it
public void ShowPanel() { objPanel.Visible = true; // remember to check if it was hidden as you will bomb on referencing
non existant stuff if (Session["hasSavedControls"] != null) { objChildControl1.Text =
Session["saveChildControl1"].Text.ToString(); objChildControl2.Text =
Session["saveChildControl2"].Text.ToString(); } }
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*******@discussions.microsoft.com> wrote in message
news:14**********************************@microsof t.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["saveChildControl1"] = objChildControl1.Text; // assuming it's a
textbox Session["saveChildControl2"] = objChildControl2.Text; Session["hasSaveControls"] = "true"; objPanel.Visible = false;
}
then to reload it
public void ShowPanel() { objPanel.Visible = true; // remember to check if it was hidden as you will bomb on referencing
non existant stuff if (Session["hasSavedControls"] != null) { objChildControl1.Text =
Session["saveChildControl1"].Text.ToString(); objChildControl2.Text =
Session["saveChildControl2"].Text.ToString(); } } This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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...
|
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......
|
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...
|
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...
|
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...
|
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
|
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...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
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...
| |