473,657 Members | 2,415 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 = "ConfirmPas swd" then%>
<TABLE border="0" class="ContentA rea" width="100%">
<TR><TD>Chang e Password?</TD></TR>
</TABLE>
<TABLE border="0" cellPadding="2" class="ContentA rea" width="100%">
<TR><TD width="27">
<form method="post" action="MyPage. asp?action=DoPa sswd" 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="ContentA rea" width="100%">
<TR><TD colSpan=2>Your password is changed.<br>
Your new password is: <b><%=update_pa ssword%></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 1617
Chung Hang Shum <ch********@yah oo.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 = "ConfirmPas swd" then%>
<TABLE border="0" class="ContentA rea" width="100%">
<TR><TD>Chang e Password?</TD></TR>
</TABLE>
<TABLE border="0" cellPadding="2" class="ContentA rea" width="100%">
<TR><TD width="27">
<form method="post" action="MyPage. asp?action=DoPa sswd" 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="ContentA rea" width="100%">
<TR><TD colSpan=2>Your password is changed.<br>
Your new password is: <b><%=update_pa ssword%></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.pnlQuestio n.Visible = false;
((label)this.pn lChange.FindCon trol("lblNewPwd ")).Text = 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="__EVENTTA RGET" value="" />
<input type="hidden" name="__EVENTAR GUMENT" value="" />
<input type="hidden" name="__VIEWSTA TE"
value="dDwtMTY4 NTYzMDIzMzs7bDx DaGFuZ2VQYXNzd2 Q7VXBncmFkZTs+P l9TZEjTS+jPjU73 Z+pj93YE9F8i"
/>

<script language="javas cript">
<!--
function __doPostBack(ev entTarget, eventArgument) {
var theform;
if (window.navigat or.appName.toLo werCase().index Of("netscape") > -1)
{
theform = document.forms["Password_chang e"];
}
else {
theform = document.Passwo rd_change;
}
theform.__EVENT TARGET.value = eventTarget.spl it("$").join(": ");
theform.__EVENT ARGUMENT.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#******* *******@TK2MSFT NGP11.phx.gbl>. ..
Chung Hang Shum <ch********@yah oo.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 = "ConfirmPas swd" then%>
<TABLE border="0" class="ContentA rea" width="100%">
<TR><TD>Chang e Password?</TD></TR>
</TABLE>
<TABLE border="0" cellPadding="2" class="ContentA rea" width="100%">
<TR><TD width="27">
<form method="post" action="MyPage. asp?action=DoPa sswd" 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="ContentA rea" width="100%">
<TR><TD colSpan=2>Your password is changed.<br>
Your new password is: <b><%=update_pa ssword%></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.pnlQuestio n.Visible = false;
((label)this.pn lChange.FindCon trol("lblNewPwd ")).Text = NewPassword;
this.pnlChange. Visible = true;

...and so on.

HTH

Nov 18 '05 #3
Chung Hang Shum <ch********@yah oo.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="__EVENTTA RGET" value="" />
<input type="hidden" name="__EVENTAR GUMENT" value="" />
<input type="hidden" name="__VIEWSTA TE"
value="dDwtMTY4 NTYzMDIzMzs7bDx DaGFuZ2VQYXNzd2 Q7VXBncmFkZTs+P l9TZEjTS+jPjU73 Z+pj93YE9F8i"
/>

<script language="javas cript">
<!--
function __doPostBack(ev entTarget, eventArgument) {
var theform;
if (window.navigat or.appName.toLo werCase().index Of("netscape") > -1)
{
theform = document.forms["Password_chang e"];
}
else {
theform = document.Passwo rd_change;
}
theform.__EVENT TARGET.value = eventTarget.spl it("$").join(": ");
theform.__EVENT ARGUMENT.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
1607
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 numbers two decimal places long like 10.01 I only know how to define numbers as int or double. Do I use float? Also, I'm using Visual Studio .NET is there anyway to keep the compiler on the screen long enough to actually see what it's outputting. ...
12
1882
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 the build fails with what the book tells me to do. Specifically, I am doing this: public authors1 GetAuthors() { authors1 authors = new Authors1();
18
2914
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? Are there better languages than c for a beginner? For instance visual basic or i should just keep the confidence of improving?
0
1064
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 my table ends up like this: When I write to another column, the program continues writing from the next row instead of returning to Row1.
2
1615
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 '', `title_alias` varchar(100) NOT NULL default '', `introtext` mediumtext NOT NULL,
5
1701
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 sides of the triangle as well as the angle in degrees. It's a monster to a beginner. we went from "Hello World" to this. please help! mac010904@yahoo.com
3
1401
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, i designed a homepage which i completely want to code in CSS and without frames. since i am such a beginner with CSS layouts, i'd like to know how i would divide my page in divs. i understand that i would create a container with a fixed size, and...
0
1191
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 on the hyperlink in a particulur cell, problem is, i only want to click on the cells that are highlighted. So question is, whats the code to make sure the macro only clicks on the cells that are highlighted? Thanks for your help, gwmarin
22
18133
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 programmer and looking for a starting point in regards to practical projects to work on. What are some projects that beginner programmers usually start with? Please list a few that would be good for a beginner PHP programmer to
0
8411
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8323
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8513
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8613
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7351
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5638
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2740
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1732
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.