Hi Rod,
Thanks for your followup. I think the routine you described in the last
reply is correct and could be a means to implement what you want. However,
I've another means if your page is not very complex. I think you may try
put those things all in the same page and when different linkbutton such as
(new, delete or update) is clicked , the page display the related part and
hide the others. In ASP.NET web page , you can use the Panel control to
contains other sub controls and you're able to show or hide a control
freely. Thus, as for the problem you mentioned, I think you can provide two
panels one contains the controls and elements which is to be shown at "new"
situation, and the other panel contains the thing which is to be shown at
"update" situation. And when "New" link is clicked, you show the "new"
panel and hide the "update" panel. Also, the same when "update" panel is
clicked. If so, you may avoid using multi pages or transfer parameters
between different pages.
To make this clearly, I've made a simple sample page , you may have a check
to see whether this is suitable for your situation:
---------------------------------------aspx
file------------------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>MultiContent</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="
http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<table width="600" align="center">
<tr>
<td colspan="2">
<asp:Label id="lblMessage" runat="server"></asp:Label><INPUT
id="hdState" type="hidden" runat="server">
</td>
</tr>
<tr>
<td colspan="2">
<table width="100%" align="center">
<tr>
<td><asp:LinkButton id="lnkMain"
runat="server">Main</asp:LinkButton></td>
<td><asp:LinkButton id="lnkNew"
runat="server">New</asp:LinkButton></td>
<td><asp:LinkButton id="lnkUpdate"
runat="server">Update</asp:LinkButton></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<asp
anel id="pnlNew" runat="server">
<TABLE width="100%" align="center">
<TR>
<TD colSpan="2">This is the New area</TD>
</TR>
<TR>
<TD>
<asp:Label id="Label1" runat="server">NewName</asp:Label></TD>
<TD>
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox></TD>
</TR>
<TR>
<TD>
<asp:Label id="Label2" runat="server">NewPassword</asp:Label>
</TD>
<TD>
<asp:TextBox id="TextBox2" runat="server"></asp:TextBox>
<asp:Button id="Button1" runat="server"
Text="Create"></asp:Button>
</TD>
</TR>
</TABLE>
</asp
anel>
</td>
</tr>
<tr>
<td>
<asp
anel id="pnlUpdate" runat="server">
<TABLE width="100%" align="center">
<TR>
<TD colSpan="2">This is the Update area</TD>
</TR>
<TR>
<TD>
<asp:Label id="Label3" runat="server">EditName</asp:Label>
</TD>
<TD>
<asp:TextBox id="TextBox3" runat="server"></asp:TextBox>
</TD>
</TR>
<TR>
<TD>
<asp:Label id="Label4" runat="server">EditPassword</asp:Label>
</TD>
<TD>
<asp:TextBox id="TextBox4" runat="server"></asp:TextBox>
<asp:Button id="Button2" runat="server"
Text="Update"></asp:Button>
</TD>
</TR>
</TABLE>
</asp
anel>
</td>
</tr>
</table>
</form>
</body>
</HTML>
----------------------------------------------------------code behind page
class --------------------------------------------------
public class MultiContent : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Panel pnlNew;
protected System.Web.UI.WebControls.Label lblMessage;
protected System.Web.UI.WebControls.LinkButton lnkMain;
protected System.Web.UI.WebControls.LinkButton lnkNew;
protected System.Web.UI.WebControls.LinkButton lnkUpdate;
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.TextBox TextBox2;
protected System.Web.UI.WebControls.Label Label3;
protected System.Web.UI.WebControls.TextBox TextBox3;
protected System.Web.UI.WebControls.Label Label4;
protected System.Web.UI.WebControls.TextBox TextBox4;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Button Button2;
protected System.Web.UI.HtmlControls.HtmlInputHidden hdState;
protected System.Web.UI.WebControls.Panel pnlUpdate;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if(!IsPostBack)
{
Do_Main();
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.lnkMain.Click += new System.EventHandler(this.lnkMain_Click);
this.lnkNew.Click += new System.EventHandler(this.lnkNew_Click);
this.lnkUpdate.Click += new System.EventHandler(this.lnkUpdate_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void lnkMain_Click(object sender, System.EventArgs e)
{
if(!hdState.Value.Equals("main"))
{
Do_Main();
}
}
private void lnkNew_Click(object sender, System.EventArgs e)
{
Do_New();
}
private void lnkUpdate_Click(object sender, System.EventArgs e)
{
Do_Update();
}
private void Do_Main()
{
pnlNew.Visible = false;
pnlUpdate.Visible = false;
hdState.Value = "main";
lblMessage.Text = "Current state is Main!";
}
private void Do_New()
{
pnlNew.Visible = true;
pnlUpdate.Visible = false;
hdState.Value = "new";
lblMessage.Text = "Current state is New!";
}
private void Do_Update()
{
pnlNew.Visible = false;
pnlUpdate.Visible = true;
hdState.Value = "update";
lblMessage.Text = "Current state is Update!";
}
}
--------------------------------------------------
Also, if you have any questions , please feel free to let me know.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure!
www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)