473,322 Members | 1,562 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,322 software developers and data experts.

Maintaining state between multiple pages in Custom WebControl

Hey all, I have finally managed to create a Custom WebControl and am using a
technique from another programmer to maintain state between pages - I would
just like to validate this idea.

Basically I have created a Custom Web Control that is capable of generating
multiple webpages. It actually only creates one webpage, but hides Panels
(that contain the web controls - TextBox's, Labels, etc) to give the
impression that the user is traversing multiple pages. The solution
definitely works - but I'm wondering if it is the "right" way to do it. I.E.
is there a "better" way of maintaining this state information.

Here is the basic idea - also please let me know if I'm creating the
controls, etc in the write methods:

public class ReportWebControl : System.Web.UI.WebControls.WebControl,
System.Web.UI.INamingContainer
{
private Panel m_panel;
private TextBox m_textBox;
private Button m_nextButton;

private Panel m_panel2;
private TextBox m_textBox2;
private Button m_nextButton2;

protected override void OnLoad(EventArgs ea)
{
}

protected override void OnInit(System.EventArgs e)
{
}

protected override void Render(HtmlTextWriter output)
{
m_panel.RenderControl(output);
m_panel2.RenderControl(output);
}

public void nextButtonClick (object origObject, EventArgs ea)
{
m_panel.Visible = false;
m_panel2.Visible = true;
}

public void testButtonClick (object origObject, EventArgs ea)
{
m_panel2.Visible = false;
m_panel.Visible = true;
}

protected override void CreateChildControls()
{
m_nextButton = new Button();
m_nextButton.Text = "Submit";
m_nextButton.Click += new EventHandler(nextButtonClick);

m_textBox = new TextBox();
m_textBox.Text = "one test";

m_panel = new Panel();
m_panel.Controls.Add(m_nextButton);
m_panel.Controls.Add(m_textBox);
Controls.Add(m_panel);
//******************************************
m_nextButton2 = new Button();
m_nextButton2.Text = "Submit - 2";
m_nextButton2.Click += new EventHandler(testButtonClick);

m_textBox2 = new TextBox();
m_textBox2.Text = "two test";

m_panel2 = new Panel();
m_panel2.Visible = false;
m_panel2.Controls.Add(m_nextButton2);
m_panel2.Controls.Add(m_textBox2);
Controls.Add(m_panel2);
}
}

Nov 18 '05 #1
1 1894
"Novice" <6tc1ATqlinkDOTqueensuDOTca> wrote in message
news:E5**********************************@microsof t.com...
Hey all, I have finally managed to create a Custom WebControl and am using
a
technique from another programmer to maintain state between pages - I
would
just like to validate this idea.

Basically I have created a Custom Web Control that is capable of
generating
multiple webpages. It actually only creates one webpage, but hides Panels
(that contain the web controls - TextBox's, Labels, etc) to give the
impression that the user is traversing multiple pages. The solution
definitely works - but I'm wondering if it is the "right" way to do it.
I.E.
is there a "better" way of maintaining this state information.


Are you experiencing a problem?.

-----
John Saunders
Nov 18 '05 #2

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

Similar topics

5
by: leegold2 | last post by:
Probably a newbie question about "state": My problem is I have a search form, so user enters a keyword <enter>, then this form posts to another page were the result are displayed. But this...
3
by: Shikari Shambu | last post by:
Hi All, I have a situation where multiple applications are sharing some pages/ controls. So, I have a separate common project that has the common pages/ controls. My question is how do I...
6
by: Mike | last post by:
I have a few textbox controls that have autopostback so that when they loose focus they update a label control that shows the count of characters in their respective text control. This works fine,...
0
by: Earl Teigrob | last post by:
I am building a custom control that I want to server as a container for child controls that can be dynamically added to this control. I can persist the child controls that are added to my custom...
9
by: McGeeky | last post by:
Is there a way to get a user control to remember its state across pages? I have a standard page layout I use with a header and footer as user controls. Each page uses the same layout by means of...
27
by: Raymond | last post by:
They say it's easier, but has anyone tried maintaining an ASP.NET site without the source code of the dlls? This was not a problem with classic ASP, all the code was almost always just in text...
4
by: Sam | last post by:
I have an asp.net 2.0 app that uses a sitemap, Master Page, and has several content pages. While this feature has simplified the process of creating a data-driven site menu, it does seem to have...
0
by: =?Utf-8?B?SkhhbGV5?= | last post by:
Our system is: IIS Server: dual Intel Xeon 2.80 GHz, 4 GB Ram Windows Server 2003 SP2 IIS 6.0 SQL Server: dual Intel Xeon 2.80 GHz, 4 GB Ram (separate server) Windows Server 2003 SP2 SQL...
4
by: Cirene | last post by:
In my web.config I added <pages enableSessionState="true">. In each of my pages I also added EnableSessionState="True" to the Page declaration. (I didn't think this was necessary, but...) ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.