467,883 Members | 1,309 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,883 developers. It's quick & easy.

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
  • viewed: 1680
Share:
1 Reply
"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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by leegold2 | last post: by
3 posts views Thread by Shikari Shambu | last post: by
6 posts views Thread by Mike | last post: by
reply views Thread by Earl Teigrob | last post: by
27 posts views Thread by Raymond | last post: by
reply views Thread by =?Utf-8?B?SkhhbGV5?= | last post: by
4 posts views Thread by Cirene | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.