Maintaining state between generated pages for Custom WebControl

N

Novice

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);
}
}

Thanks,
Novice
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top