By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,876 Members | 1,239 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,876 IT Pros & Developers. It's quick & easy.

Maintaining state between multiple pages in Custom WebControl

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
"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.