473,387 Members | 1,530 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

panel's controls

Hi,

If I make a control that derives from panel, how can I persist the state of
the controls that are inside the panel when it is not rendered (visible =
false)?

The reason for this is that I'm making a custom user control that derives
from the Panel class. In the render method, I render some stuff and then I
do base.render if the panel is to be visible. If it's to be hidden, I don't
render it, but when I render it again, the controls that I've put in my
control at design time are all reset.) I think I'm missing something in this
:)

Thank you
Nov 18 '05 #1
4 1772
Can you give me an example of what you have within your panel? I just tried a simple example of my own and it persisted attributes I set at design time after I toggled the panel visible/invisible.
--Michael

Here is what I did

Public Class Panel : Inherits System.web.ui.webcontrols.Panel
Protected Overrides Sub Render(ByVal Output As HtmlTextWriter)
MyBase.Render(Output)
End Sub
End Class

<%@ Register TagPrefix="tnc" Namespace="tnc" Assembly="tnc" %>
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="Intranet.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>WebForm1</title>
</head>
<body>

<form id="Form1" method="post" runat="server">
<tnc:panel id="pnlTest" runat="server">
<asp:textbox id="txtTest" runat="server" text="Hello!"></asp:textbox>
</tnc:panel>
<asp:button id="btnText" runat="server" text="Toggle"></asp:button>
</form>

</body>
</html>

Private Sub btnText_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnText.Click
If pnlTest.visible = False Then
pnlTest.Visible = True
Else
pnlTest.Visible = False
End If
End Sub

"Alexandre Soares" <so*********@hotmail.com> wrote in message news:Oe**************@TK2MSFTNGP10.phx.gbl...
Hi,

If I make a control that derives from panel, how can I persist the state of
the controls that are inside the panel when it is not rendered (visible =
false)?

The reason for this is that I'm making a custom user control that derives
from the Panel class. In the render method, I render some stuff and then I
do base.render if the panel is to be visible. If it's to be hidden, I don't
render it, but when I render it again, the controls that I've put in my
control at design time are all reset.) I think I'm missing something in this
:)

Thank you

Nov 18 '05 #2
I modified my example so that it fits what you did and you're right, the
info is persisted. However, in my original example, the button that
shows/hides the panel is rendered in the render method of the user control.
So in this render method, I always want to render the button, but not the
base panel. So if I do something like:

Protected Overrides Sub Render(ByVal Output As HtmlTextWriter)
button.Render(output)
if(panel must be visible) then
MyBase.Render(Output)
end if
End Sub

then the controls properties (like text) are not persisted. I don't know
why... :)
"Raterus" <ra*****@spam.org> a écrit dans le message de
news:%2****************@TK2MSFTNGP11.phx.gbl...
Can you give me an example of what you have within your panel? I just tried
a simple example of my own and it persisted attributes I set at design time
after I toggled the panel visible/invisible.
--Michael

Here is what I did

Public Class Panel : Inherits System.web.ui.webcontrols.Panel
Protected Overrides Sub Render(ByVal Output As HtmlTextWriter)
MyBase.Render(Output)
End Sub
End Class

<%@ Register TagPrefix="tnc" Namespace="tnc" Assembly="tnc" %>
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb"
Inherits="Intranet.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>WebForm1</title>
</head>
<body>

<form id="Form1" method="post" runat="server">
<tnc:panel id="pnlTest" runat="server">
<asp:textbox id="txtTest" runat="server" text="Hello!"></asp:textbox>
</tnc:panel>
<asp:button id="btnText" runat="server" text="Toggle"></asp:button>
</form>

</body>
</html>

Private Sub btnText_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnText.Click
If pnlTest.visible = False Then
pnlTest.Visible = True
Else
pnlTest.Visible = False
End If
End Sub

"Alexandre Soares" <so*********@hotmail.com> wrote in message
news:Oe**************@TK2MSFTNGP10.phx.gbl...
Hi,

If I make a control that derives from panel, how can I persist the state of the controls that are inside the panel when it is not rendered (visible =
false)?

The reason for this is that I'm making a custom user control that derives
from the Panel class. In the render method, I render some stuff and then I
do base.render if the panel is to be visible. If it's to be hidden, I don't render it, but when I render it again, the controls that I've put in my
control at design time are all reset.) I think I'm missing something in this :)

Thank you

Nov 18 '05 #3
Actually my button is an anchor tag that fires a javascript postback (my
class implements IPostBackEventHandler to catch the postback event and
change the panel visibility state)

"Raterus" <ra*****@spam.org> a écrit dans le message de
news:%2****************@TK2MSFTNGP11.phx.gbl...
Can you give me an example of what you have within your panel? I just tried
a simple example of my own and it persisted attributes I set at design time
after I toggled the panel visible/invisible.
--Michael

Here is what I did

Public Class Panel : Inherits System.web.ui.webcontrols.Panel
Protected Overrides Sub Render(ByVal Output As HtmlTextWriter)
MyBase.Render(Output)
End Sub
End Class

<%@ Register TagPrefix="tnc" Namespace="tnc" Assembly="tnc" %>
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb"
Inherits="Intranet.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>WebForm1</title>
</head>
<body>

<form id="Form1" method="post" runat="server">
<tnc:panel id="pnlTest" runat="server">
<asp:textbox id="txtTest" runat="server" text="Hello!"></asp:textbox>
</tnc:panel>
<asp:button id="btnText" runat="server" text="Toggle"></asp:button>
</form>

</body>
</html>

Private Sub btnText_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnText.Click
If pnlTest.visible = False Then
pnlTest.Visible = True
Else
pnlTest.Visible = False
End If
End Sub

"Alexandre Soares" <so*********@hotmail.com> wrote in message
news:Oe**************@TK2MSFTNGP10.phx.gbl...
Hi,

If I make a control that derives from panel, how can I persist the state of the controls that are inside the panel when it is not rendered (visible =
false)?

The reason for this is that I'm making a custom user control that derives
from the Panel class. In the render method, I render some stuff and then I
do base.render if the panel is to be visible. If it's to be hidden, I don't render it, but when I render it again, the controls that I've put in my
control at design time are all reset.) I think I'm missing something in this :)

Thank you

Nov 18 '05 #4
Do you realize that sub Render will never be called if the control.visible = false ?
So checking for visibility in Render is pointless, since it will always be true.

"Alexandre Soares" <so*********@hotmail.com> wrote in message news:Ov**************@tk2msftngp13.phx.gbl...
I modified my example so that it fits what you did and you're right, the
info is persisted. However, in my original example, the button that
shows/hides the panel is rendered in the render method of the user control.
So in this render method, I always want to render the button, but not the
base panel. So if I do something like:

Protected Overrides Sub Render(ByVal Output As HtmlTextWriter)
button.Render(output)
if(panel must be visible) then
MyBase.Render(Output)
end if
End Sub

then the controls properties (like text) are not persisted. I don't know
why... :)


"Raterus" <ra*****@spam.org> a écrit dans le message de
news:%2****************@TK2MSFTNGP11.phx.gbl...
Can you give me an example of what you have within your panel? I just tried
a simple example of my own and it persisted attributes I set at design time
after I toggled the panel visible/invisible.
--Michael

Here is what I did

Public Class Panel : Inherits System.web.ui.webcontrols.Panel
Protected Overrides Sub Render(ByVal Output As HtmlTextWriter)
MyBase.Render(Output)
End Sub
End Class

<%@ Register TagPrefix="tnc" Namespace="tnc" Assembly="tnc" %>
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb"
Inherits="Intranet.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>WebForm1</title>
</head>
<body>

<form id="Form1" method="post" runat="server">
<tnc:panel id="pnlTest" runat="server">
<asp:textbox id="txtTest" runat="server" text="Hello!"></asp:textbox>
</tnc:panel>
<asp:button id="btnText" runat="server" text="Toggle"></asp:button>
</form>

</body>
</html>

Private Sub btnText_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnText.Click
If pnlTest.visible = False Then
pnlTest.Visible = True
Else
pnlTest.Visible = False
End If
End Sub



"Alexandre Soares" <so*********@hotmail.com> wrote in message
news:Oe**************@TK2MSFTNGP10.phx.gbl...
Hi,

If I make a control that derives from panel, how can I persist the state

of
the controls that are inside the panel when it is not rendered (visible =
false)?

The reason for this is that I'm making a custom user control that derives
from the Panel class. In the render method, I render some stuff and then I
do base.render if the panel is to be visible. If it's to be hidden, I

don't
render it, but when I render it again, the controls that I've put in my
control at design time are all reset.) I think I'm missing something in

this
:)

Thank you


Nov 18 '05 #5

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

Similar topics

1
by: Robert Skidmore | last post by:
I am building an application that will fade one panel to another panel. Both panels will have picture boxes in them (thumbnails). This is what I have tried: private void...
2
by: theComputer7 | last post by:
I cut down the code to make this half way understandable... I have read Data Grid girls caution about over use of dynamic controls. I truly believe what I am doing requires dynamically inserted...
0
by: AinO | last post by:
Hi, (VS2003/c# - System.Windows.Forms) I have two panels on a parent panel, where one is docked top and the second docked client area. They both have their Visible property = false at design...
5
by: Robert Phillips | last post by:
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...
2
by: scorpion53061 | last post by:
I have several dynamically created controls which exist on a form. When it comes to time to use the panel I add the controls to the panel e.g. Panel1.Controls.Add(Button1) and so on and so...
3
by: John Salerno | last post by:
I'm using the sample code of the file 'simple.py' and trying to make a single window with a panel in it, but I keep getting an error. Here's my code: (I know I might need something else, like a...
8
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...
1
by: Steve Richter | last post by:
a simple web page that adds controls to a Panel control at run time. Problem is, on PostBack, all the controls I added to the Panel are missing! ViewState is enabled on the panel. What happened to...
1
by: mbruyns | last post by:
i have been trying (and sometimes succeeding) to use the modalpopupextender to show various panels of controls on my asp pages. the strange problem that i keep on running into is that sometimes it...
2
by: =?Utf-8?B?TUNN?= | last post by:
I have an asp.net page that contains an update panel. Within the update panel, controls get added dynamically. During partial page post backs the controls within the panel will change. I have a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
jinu1996
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 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.