473,545 Members | 2,011 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 ReportWebContro l : System.Web.UI.W ebControls.WebC ontrol,
System.Web.UI.I NamingContainer
{
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(EventArg s ea)
{
}

protected override void OnInit(System.E ventArgs e)
{
}

protected override void Render(HtmlText Writer output)
{
m_panel.RenderC ontrol(output);
m_panel2.Render Control(output) ;
}

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

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

protected override void CreateChildCont rols()
{
m_nextButton = new Button();
m_nextButton.Te xt = "Submit";
m_nextButton.Cl ick += new EventHandler(ne xtButtonClick);

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

m_panel = new Panel();
m_panel.Control s.Add(m_nextBut ton);
m_panel.Control s.Add(m_textBox );
Controls.Add(m_ panel);
//*************** *************** ************
m_nextButton2 = new Button();
m_nextButton2.T ext = "Submit - 2";
m_nextButton2.C lick += new EventHandler(te stButtonClick);

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

m_panel2 = new Panel();
m_panel2.Visibl e = false;
m_panel2.Contro ls.Add(m_nextBu tton2);
m_panel2.Contro ls.Add(m_textBo x2);
Controls.Add(m_ panel2);
}
}

Nov 18 '05 #1
1 1907
"Novice" <6tc1ATqlinkDOT queensuDOTca> wrote in message
news:E5******** *************** ***********@mic rosoft.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
2246
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 display page uses pagination to break the results up into several subsequent pages. The 1st page is OK, but 2nd...last display pages loose the key word...
3
2780
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 reference these pages/ controls from my ASP.NET web projects WEbApp1 url http://localhost/app1 C:\Apps\App1
6
1378
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, except that after the postback, the page is shown reset -- scrolled to the top and with no control having focus. Can I maintain scroll/focus w/o...
0
1762
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 control but can to get them to retain view state. Below is a striped down version of my control. It exposes one property of type...
9
5296
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 copy paste (I hear this will improve in ASP.Net 2 via master pages). When I navigate from one page to the next the header and footer user controls...
27
1855
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 files, easily viewable and most importantly readily AVAILABLE on the site, to anyone access to the site's folder. But just imagine, bunch of...
4
4320
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 some big restrictions. Namely, maintaining state on the Master Page across all content pages. I simply want to keep track of a key value across all...
0
2204
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 Server 2000 We are having some problems with a website we are developing, and had some
4
2507
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...) Any reason why even though I did this I keep getting this error.... Server Error in '/abc' Application.
0
7409
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7921
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7771
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...
0
5982
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5343
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...
0
4958
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...
0
3465
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...
0
3446
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1900
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

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.