Chung Hang Shum <ch********@yahoo.com> typed:
I'm a beginner in ASP.Net. I'd wroten mange asp code before and now I
need to transfer them from asp to asp.Net.
In classical ASP you can write code like this:
<% If strRequest = "ConfirmPasswd" then%>
<TABLE border="0" class="ContentArea" width="100%">
<TR><TD>Change Password?</TD></TR>
</TABLE>
<TABLE border="0" cellPadding="2" class="ContentArea" width="100%">
<TR><TD width="27">
<form method="post" action="MyPage.asp?action=DoPasswd" id=form3
name=form3>
<input type="submit" value="OK" id=submit2 name=submit2>
</form></TD><TD>
<form method="post" action="MyPage.asp">
<input type="submit" value="Cancel">
</form>
</TD></TR></TABLE>
<% ElseIf strRequest = "DoPasswd" Then%>
<TABLE border="0" cellPadding="2" class="ContentArea" width="100%">
<TR><TD colSpan=2>Your password is changed.<br>
Your new password is: <b><%=update_password%></b><br>
</TD></TR>
<TR><TD>
<form method="post" action="MyPage.asp">
<input type="submit" value="OK">
</form>
</TD></TR></TABLE>
<% ElseIf strRequest = "something" Then%>
..........
<% End if %>
How can I do this in ASP.Net? I write in C# and use code-behind.
I have tried Literal control, but it didn't work. All I got is a
hidden input field with name _ViewState.
Can somebody help me please?
Chung Hang Shum
First of all I suggest you to use this tutorial
http://www.asp.net/Tutorials/quickstart.aspx to be confident with ASP.NET.
In particular see differences between ASP and ASP.NET (PostBack paradigm,
etc).
To resolve your issue I propose you to use some panels webcontrol. Insert in
each panel the control you want to show in it. Than use the visible property
to show/hide the panel. For example you could have:
***ASPX***
<asp:panel id="pnlQuestion" runat="server" visible="true">
<asp:label id="lblChange" runat="server">Change Password ?</asp:label>
<br><br>
<asp:button id="btnConfirm" runat="server" /> <asp:button
id="btnBack" runat="server" />
</asp:panel>
<asp:panel id="pnlChange" runat="server" visible="false">
<asp:label id="lblMessage" runat="server">Your new password is:
</asp:label>
<asp:label id="lblNewPwd" runat="server" />
<br>
<br>
<asp:button id="btnOk" runat="server" />
</asp:panel>
In the code behind, in the method delegate for the btnConfirm click event,
you should have a snippet of code like this:
***Code Behind***
//code to calculate new password
this.pnlQuestion.Visible = false;
((label)this.pnlChange.FindControl("lblNewPwd")).T ext = NewPassword;
this.pnlChange.Visible = true;
....and so on.
HTH
--
Davide Vernole
MVP ASP/ASP.NET
Microsoft Certified Solution Developer