473,396 Members | 2,018 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

A beginner needs help!

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
Nov 18 '05 #1
3 1611
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" /> &nbsp; <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>
&nbsp; <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
Nov 18 '05 #2
Thanks.
I did just as you said, but I can't set Text field in the label child
control.
All I get is:
<input type="hidden" name="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" value="" />
<input type="hidden" name="__VIEWSTATE"
value="dDwtMTY4NTYzMDIzMzs7bDxDaGFuZ2VQYXNzd2Q7VXB ncmFkZTs+Pl9TZEjTS+jPjU73Z+pj93YE9F8i"
/>

<script language="javascript">
<!--
function __doPostBack(eventTarget, eventArgument) {
var theform;
if (window.navigator.appName.toLowerCase().indexOf("n etscape") > -1)
{
theform = document.forms["Password_change"];
}
else {
theform = document.Password_change;
}
theform.__EVENTTARGET.value = eventTarget.split("$").join(":");
theform.__EVENTARGUMENT.value = eventArgument;
theform.submit();
}
// -->
</script>
Why? What have I done wrong?

Chung Hang
"Davide Vernole [MVP]" <da****@online.knodev.com> wrote in message news:<e#**************@TK2MSFTNGP11.phx.gbl>...
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" /> &nbsp; <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>
&nbsp; <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

Nov 18 '05 #3
Chung Hang Shum <ch********@yahoo.com> typed:
Thanks.
I did just as you said, but I can't set Text field in the label child
control.
All I get is:
<input type="hidden" name="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" value="" />
<input type="hidden" name="__VIEWSTATE"
value="dDwtMTY4NTYzMDIzMzs7bDxDaGFuZ2VQYXNzd2Q7VXB ncmFkZTs+Pl9TZEjTS+jPjU73Z+pj93YE9F8i"
/>

<script language="javascript">
<!--
function __doPostBack(eventTarget, eventArgument) {
var theform;
if (window.navigator.appName.toLowerCase().indexOf("n etscape") > -1)
{
theform = document.forms["Password_change"];
}
else {
theform = document.Password_change;
}
theform.__EVENTTARGET.value = eventTarget.split("$").join(":");
theform.__EVENTARGUMENT.value = eventArgument;
theform.submit();
}
// -->
</script>
Why? What have I done wrong?

Chung Hang


Is this all your web form ? I think no !
Please post all the aspx page content and the relative code behind or the
part where you implement my suggestions.
Follow my suggest and read the tutorial. In the tutorial you can find some
useful samples.

--
Davide Vernole
MVP ASP/ASP.NET
Microsoft Certified Solution Developer
Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: BobJohnson | last post by:
Just started learning C++ and I need some help with my homework, shouldn't take long for people around here. I need to create a simple money calculator but I don't know how to make the output...
12
by: Blaze | last post by:
I am doing the first walk through on the Visual Studio .Net walkthrough book to learn a little about programming. I am having issues with the first tutorial not running correctly. It seems that...
18
by: mitchellpal | last post by:
Hi guys, am learning c as a beginner language and am finding it rough especially with pointers and data files. What do you think, am i being too pessimistic or thats how it happens for a beginner?...
0
by: Jarkko Turpeinen | last post by:
I'm a beginner in XML language and I'm trying to create an XML file that could be viewed in Excel as a table that has rows and columns like this: Q1 Q2 Row1 3 5 Row2 4 1 Row3 2 3 But...
2
by: stargate03 | last post by:
Hi there I have a MYSQL database which has the following table CREATE TABLE `#__content` ( `id` int(11) unsigned NOT NULL auto_increment, `title` varchar(100) NOT NULL default '', ...
5
by: mac010904 | last post by:
i'm new to java an have an assignment. i need to write a program that will calculate the sides of a triangle using x and y coordinates.also, it should provide the area, perimeter and lengths of the...
3
by: anke | last post by:
hi all, i am fairly new to css. i know the very basics, can work with scripts and adapt them. i learned webdesign in the late 90ies and have troubles forget about my beloved tables ;-) anyway,...
0
by: gwmarin | last post by:
Hello, i am a complete beginner with visual basic so lets see if i can explain my problem. I've got microsoft excel 2003 which has got Visual Basic 6.5 and i need to create a macro which will click...
22
by: ddg_linux | last post by:
I have been reading about and doing a lot of php code examples from books but now I find myself wanting to do something practical with some of the skills that I have learned. I am a beginner php...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.