473,372 Members | 1,636 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,372 software developers and data experts.

VB to C sharp anyone can point out which is the equivalent

I'm learning C sharp and do not like vb much. I'm creatiing a wepage using
panel to test myself. I tried to use these code below, which is written in
VB, and to transform them to c sharp but I got hard time to understand vb
syntax. I don't know if anyone in here can point out which is the equivalent
object used in c sharp.

Translate these two lines to C sharp:

Sub Next_Click(Sender As Object, e As EventArgs)
Select Case Sender.Parent.ID
Thanks

<%@ Page Language="vb" %>
<html>
<head>
<script runat="server">
Sub Page_Load()
If Not IsPostBack Then
Step1.Font.Bold = True
End If
End Sub
Sub Next_Click(Sender As Object, e As EventArgs)
Select Case Sender.Parent.ID
Case "Page1"
Page1.Visible = False
Step1.Font.Bold = False
Page2.Visible = True
Step2.Font.Bold = True
Case "Page2"
Page2.Visible = False
Step2.Font.Bold = False
Page3.Visible = True
Step3.Font.Bold = True
ReviewFName.Text &= FirstName.Text
ReviewMName.Text &= MiddleName.Text
ReviewLName.Text &= LastName.Text
ReviewEmail.Text &= Email.Text
ReviewAddress.Text &= Address.Text
ReviewCity.Text &= City.Text
ReviewState.Text &= State.Text
ReviewZip.Text &= Zip.Text
End Select
End Sub

Sub Previous_Click(Sender As Object, e As EventArgs)
Select Case Sender.Parent.ID
Case "Page2"
Page2.Visible = False
Step2.Font.Bold = False
Page1.Visible = True
Step1.Font.Bold = True
Case "Page3"
Page3.Visible = False
Step3.Font.Bold = False
Page2.Visible = True
Step2.Font.Bold = True
End Select
End Sub
</script>
<style type="text/css">
div
{
background:silver;
width:400px;
border:2px outset;
margin:5px;
padding:5px;
}
</style>
</head>
<body>
<form runat="server">
<asp:label id="RegWiz" text="Registration Wizard" font-bold="true"
font-size="16" font-name="verdana" runat="server"/>
<br/>
<asp:label id="Step1" text="Step 1: Enter Personal Info"
font-name="verdana" runat="server"/>
<br/>
<asp:label id="Step2" text="Step 2: Enter Address Info"
font-name="verdana" runat="server"/>
<br/>
<asp:label id="Step3" text="Step 3: Review" font-name="verdana"
runat="server"/>
<br/>
<asp:panel id="Page1" runat="server">
<table align="center">
<tr>
<td>
<asp:label id="FirstNameLabel" text="First Name:"
runat="server"/>
</td>
<td>
<asp:textbox id="FirstName" runat="server"/>
</td>
</tr>
<tr>
<td>
<asp:label id="MiddleNameLabel" text="Middle Name:"
runat="server"/>
</td>
<td>
<asp:textbox id="MiddleName" runat="server"/>
</td>
</tr>
<tr>
<td>
<asp:label id="LastNameLabel" text="Last Name:"
runat="server"/>
</td>
<td>
<asp:textbox id="LastName" runat="server"/>
</td>
</tr>
<tr>
<td>
<asp:label id="EmailLabel" text="Email:" runat="server"/>
</td>
<td>
<asp:textbox id="Email" runat="server"/>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<asp:button id="P1Previous" Text="Previous"
enabled="false" onclick="Previous_Click" runat="server"/>
<asp:button id="P1Next" Text="Next" onclick="Next_Click"
runat="server"/>
<input id="P1Reset" type="reset" runat="server"/>
</td>
</tr>
</table>
</asp:panel>
<asp:panel id="Page2" visible="false" runat="server">
<table align="center">
<tr>
<td>
<asp:label id="AddressLabel" text="Street Address:"
runat="server"/>
</td>
<td>
<asp:textbox id="Address" runat="server"/>
</td>
</tr>
<tr>
<td>
<asp:label id="CityLabel" text="City:" runat="server"/>
</td>
<td>
<asp:textbox id="City" runat="server"/>
</td>
</tr>
<tr>
<td>
<asp:label id="StateLabel" text="State:" runat="server"/>
</td>
<td>
<asp:textbox id="State" runat="server"/>
</td>
</tr>
<tr>
<td>
<asp:label id="ZipLabel" text="Zip Code:" runat="server"/>
</td>
<td>
<asp:textbox id="Zip" runat="server"/>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<asp:button id="P2Previous" Text="Previous"
onclick="Previous_Click" runat="server"/>
<asp:button id="P2Next" Text="Next" onclick="Next_Click"
runat="server"/>
<input id="P2Reset" type="reset" runat="server"/>
</td>
</tr>
</table>
</asp:panel>
<asp:panel id="Page3" visible="false" runat="server">
<table align="center">
<tr>
<td colspan="2">
<asp:label id="ReviewFName" text="First Name: "
runat="server"/>
</td>
</tr>
<tr>
<td colspan="2">
<asp:label id="ReviewMName" text="Middle Name: "
runat="server"/>
</td>
</tr>
<tr>
<td colspan="2">
<asp:label id="ReviewLName" text="Last Name: "
runat="server"/>
</td>
</tr>
<tr>
<td colspan="2">
<asp:label id="ReviewEmail" text="Email: "
runat="server"/>
</td>
</tr>
<tr>
<td colspan="2">
<asp:label id="ReviewAddress" text="Address: "
runat="server"/>
</td>
</tr>
<tr>
<td colspan="2">
<asp:label id="ReviewCity" text="City: " runat="server"/>
</td>
</tr>
<tr>
<td colspan="2">
<asp:label id="ReviewState" text="State: "
runat="server"/>
</td>
</tr>
<tr>
<td colspan="2">
<asp:label id="ReviewZip" text="Zip: " runat="server"/>
</td>
</tr>
<tr>
<td colspan="2">
<asp:button id="P3Previous" Text="Previous"
onclick="Previous_Click" runat="server"/>
<asp:button id="P3Next" Text="Next" enabled="false"
onclick="Next_Click" runat="server"/>
<input id="P3Reset" type="reset" disabled="true"
runat="server"/>
</td>
</td>
</tr>
</table>
</asp:panel>
</form>
</body>
</html>
Nov 15 '05 #1
4 2481
On Wed, 7 Jan 2004 15:06:04 -0600, "Hai Nguyen"
<ha******@neo.tamu.edu> wrote:
I'm learning C sharp and do not like vb much. I'm creatiing a wepage using
panel to test myself. I tried to use these code below, which is written in
VB, and to transform them to c sharp but I got hard time to understand vb
syntax. I don't know if anyone in here can point out which is the equivalent
object used in c sharp.

Translate these two lines to C sharp:

Sub Next_Click(Sender As Object, e As EventArgs)
Select Case Sender.Parent.ID


It will be something along the lines of:

private void next_click(object sender, System.EventArgs e) {

switch (sender.Parent.ID) {
case x:
//code
break;
case y:
//code
break;
case n:
//code
break;
default:
//code
break;
}

....

}
Nov 15 '05 #2
>
Translate these two lines to C sharp:

Sub Next_Click(Sender As Object, e As EventArgs)
Select Case Sender.Parent.ID
Below is a sample "translation":

private void Next_Click(object Sender, System.EventArgs e)
{
switch (Sender.ParentID)
{
case "Page1":
// ...
break;
case "Page2":
// ...
break;
default:
// ...
break;
}
}

Cheers,
Christian T. [MSFT]
Visual Studio Update Team

- Please do not reply to this email directly. This email is for newsgroup
purposes only.
================================================== =======================
This posting is provided "AS IS" with no warranties, and confers no
rights. Use of included script samples are subject to the terms specified
at http://www.microsoft.com/info/cpyright.htm

Note: For the benefit of the community-at-large, all responses to this
message are best directed to the newsgroup/thread from which
they originated.
================================================== =======================

--------------------From: "Hai Nguyen" <ha******@neo.tamu.edu>
Subject: VB to C sharp anyone can point out which is the equivalent
Date: Wed, 7 Jan 2004 15:06:04 -0600
Lines: 248
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <uW**************@TK2MSFTNGP11.phx.gbl>
Newsgroups: microsoft.public.dotnet.languages.csharp
NNTP-Posting-Host: eslnt01.tamu.edu 165.91.212.76
Path: cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!cpmsftng xa09.phx.gbl!TK2MSFTNGP08.
phx.gbl!TK2MSFTNGP11.phx.gblXref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.languages.csharp:210149
X-Tomcat-NG: microsoft.public.dotnet.languages.csharp

I'm learning C sharp and do not like vb much. I'm creatiing a wepage using
panel to test myself. I tried to use these code below, which is written in
VB, and to transform them to c sharp but I got hard time to understand vb
syntax. I don't know if anyone in here can point out which is the equivalentobject used in c sharp.

Translate these two lines to C sharp:

Sub Next_Click(Sender As Object, e As EventArgs)
Select Case Sender.Parent.ID
Thanks

<%@ Page Language="vb" %>
<html>
<head>
<script runat="server">
Sub Page_Load()
If Not IsPostBack Then
Step1.Font.Bold = True
End If
End Sub
Sub Next_Click(Sender As Object, e As EventArgs)
Select Case Sender.Parent.ID
Case "Page1"
Page1.Visible = False
Step1.Font.Bold = False
Page2.Visible = True
Step2.Font.Bold = True
Case "Page2"
Page2.Visible = False
Step2.Font.Bold = False
Page3.Visible = True
Step3.Font.Bold = True
ReviewFName.Text &= FirstName.Text
ReviewMName.Text &= MiddleName.Text
ReviewLName.Text &= LastName.Text
ReviewEmail.Text &= Email.Text
ReviewAddress.Text &= Address.Text
ReviewCity.Text &= City.Text
ReviewState.Text &= State.Text
ReviewZip.Text &= Zip.Text
End Select
End Sub

Sub Previous_Click(Sender As Object, e As EventArgs)
Select Case Sender.Parent.ID
Case "Page2"
Page2.Visible = False
Step2.Font.Bold = False
Page1.Visible = True
Step1.Font.Bold = True
Case "Page3"
Page3.Visible = False
Step3.Font.Bold = False
Page2.Visible = True
Step2.Font.Bold = True
End Select
End Sub
</script>
<style type="text/css">
div
{
background:silver;
width:400px;
border:2px outset;
margin:5px;
padding:5px;
}
</style>
</head>
<body>
<form runat="server">
<asp:label id="RegWiz" text="Registration Wizard" font-bold="true"
font-size="16" font-name="verdana" runat="server"/>
<br/>
<asp:label id="Step1" text="Step 1: Enter Personal Info"
font-name="verdana" runat="server"/>
<br/>
<asp:label id="Step2" text="Step 2: Enter Address Info"
font-name="verdana" runat="server"/>
<br/>
<asp:label id="Step3" text="Step 3: Review" font-name="verdana"
runat="server"/>
<br/>
<asp:panel id="Page1" runat="server">
<table align="center">
<tr>
<td>
<asp:label id="FirstNameLabel" text="First Name:"
runat="server"/>
</td>
<td>
<asp:textbox id="FirstName" runat="server"/>
</td>
</tr>
<tr>
<td>
<asp:label id="MiddleNameLabel" text="Middle Name:"
runat="server"/>
</td>
<td>
<asp:textbox id="MiddleName" runat="server"/>
</td>
</tr>
<tr>
<td>
<asp:label id="LastNameLabel" text="Last Name:"
runat="server"/>
</td>
<td>
<asp:textbox id="LastName" runat="server"/>
</td>
</tr>
<tr>
<td>
<asp:label id="EmailLabel" text="Email:" runat="server"/>
</td>
<td>
<asp:textbox id="Email" runat="server"/>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<asp:button id="P1Previous" Text="Previous"
enabled="false" onclick="Previous_Click" runat="server"/>
<asp:button id="P1Next" Text="Next" onclick="Next_Click"
runat="server"/>
<input id="P1Reset" type="reset" runat="server"/>
</td>
</tr>
</table>
</asp:panel>
<asp:panel id="Page2" visible="false" runat="server">
<table align="center">
<tr>
<td>
<asp:label id="AddressLabel" text="Street Address:"
runat="server"/>
</td>
<td>
<asp:textbox id="Address" runat="server"/>
</td>
</tr>
<tr>
<td>
<asp:label id="CityLabel" text="City:" runat="server"/>
</td>
<td>
<asp:textbox id="City" runat="server"/>
</td>
</tr>
<tr>
<td>
<asp:label id="StateLabel" text="State:" runat="server"/>
</td>
<td>
<asp:textbox id="State" runat="server"/>
</td>
</tr>
<tr>
<td>
<asp:label id="ZipLabel" text="Zip Code:" runat="server"/> </td>
<td>
<asp:textbox id="Zip" runat="server"/>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<asp:button id="P2Previous" Text="Previous"
onclick="Previous_Click" runat="server"/>
<asp:button id="P2Next" Text="Next" onclick="Next_Click"
runat="server"/>
<input id="P2Reset" type="reset" runat="server"/>
</td>
</tr>
</table>
</asp:panel>
<asp:panel id="Page3" visible="false" runat="server">
<table align="center">
<tr>
<td colspan="2">
<asp:label id="ReviewFName" text="First Name: "
runat="server"/>
</td>
</tr>
<tr>
<td colspan="2">
<asp:label id="ReviewMName" text="Middle Name: "
runat="server"/>
</td>
</tr>
<tr>
<td colspan="2">
<asp:label id="ReviewLName" text="Last Name: "
runat="server"/>
</td>
</tr>
<tr>
<td colspan="2">
<asp:label id="ReviewEmail" text="Email: "
runat="server"/>
</td>
</tr>
<tr>
<td colspan="2">
<asp:label id="ReviewAddress" text="Address: "
runat="server"/>
</td>
</tr>
<tr>
<td colspan="2">
<asp:label id="ReviewCity" text="City: " runat="server"/>
</td>
</tr>
<tr>
<td colspan="2">
<asp:label id="ReviewState" text="State: "
runat="server"/>
</td>
</tr>
<tr>
<td colspan="2">
<asp:label id="ReviewZip" text="Zip: " runat="server"/>
</td>
</tr>
<tr>
<td colspan="2">
<asp:button id="P3Previous" Text="Previous"
onclick="Previous_Click" runat="server"/>
<asp:button id="P3Next" Text="Next" enabled="false"
onclick="Next_Click" runat="server"/>
<input id="P3Reset" type="reset" disabled="true"
runat="server"/>
</td>
</td>
</tr>
</table>
</asp:panel>
</form>
</body>
</html>


Nov 15 '05 #3
It did not work, would you please tell me more. This is the error it throws
after I used you way: I don't know if i have to import anything

public void Next_Click(object sender, System.EventArgs e)

{

switch(sender.Parent.ID)

.....
}

the only object works I tried was this.Parent.ID but when I ran it it failed

please more insutructions
-------------------

code:

using System;

using System.Collections;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Web;

using System.Web.SessionState;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.HtmlControls;

namespace Energy

{

/// <summary>

/// Summary description for panel.

/// </summary>

public class panel : System.Web.UI.Page

{

protected System.Web.UI.WebControls.Label RegWiz;

protected System.Web.UI.WebControls.Label Step1;

protected System.Web.UI.WebControls.Label Step2;

protected System.Web.UI.WebControls.Label Step3;

protected System.Web.UI.WebControls.Label FirstNameLabel;

protected System.Web.UI.WebControls.TextBox FirstName;

protected System.Web.UI.WebControls.Label MiddleNameLabel;

protected System.Web.UI.WebControls.TextBox MiddleName;

protected System.Web.UI.WebControls.Label LastNameLabel;

protected System.Web.UI.WebControls.TextBox LastName;

protected System.Web.UI.WebControls.Label EmailLabel;

protected System.Web.UI.WebControls.TextBox Email;

protected System.Web.UI.WebControls.Button P1Previous;

protected System.Web.UI.WebControls.Button P1Next;

protected System.Web.UI.WebControls.Panel Page1;

protected System.Web.UI.WebControls.Label AddressLabel;

protected System.Web.UI.WebControls.TextBox Address;

protected System.Web.UI.WebControls.Label CityLabel;

protected System.Web.UI.WebControls.TextBox City;

protected System.Web.UI.WebControls.Label StateLabel;

protected System.Web.UI.WebControls.TextBox State;

protected System.Web.UI.WebControls.Label ZipLabel;

protected System.Web.UI.WebControls.TextBox Zip;

protected System.Web.UI.WebControls.Button P2Previous;

protected System.Web.UI.WebControls.Button P2Next;

protected System.Web.UI.WebControls.Panel Page2;

protected System.Web.UI.WebControls.Label ReviewFName;

protected System.Web.UI.WebControls.Label ReviewMName;

protected System.Web.UI.WebControls.Label ReviewLName;

protected System.Web.UI.WebControls.Label ReviewEmail;

protected System.Web.UI.WebControls.Label ReviewAddress;

protected System.Web.UI.WebControls.Label ReviewCity;

protected System.Web.UI.WebControls.Label ReviewState;

protected System.Web.UI.WebControls.Label ReviewZip;

protected System.Web.UI.WebControls.Button P3Previous;

protected System.Web.UI.WebControls.Button P3Next;

protected System.Web.UI.WebControls.Panel Page3;

protected System.Web.UI.HtmlControls.HtmlInputButton P1Reset;

protected System.Web.UI.HtmlControls.HtmlInputButton P2Reset;

protected System.Web.UI.HtmlControls.HtmlInputButton P3Reset;
private void Page_Load(object sender, System.EventArgs e)

{

if(!Page.IsPostBack)

{

Step1.Font.Bold = true;

}
}
public void Next_Click(object sender, System.EventArgs e)

{

switch(sender.Parent.ID)

{

case "Page1": Page1.Visible = False;

Step1.Font.Bold = False;

Page2.Visible = True;

Step2.Font.Bold = True;

break;

case "Page2": Page2.Visible = False;

Step2.Font.Bold = False;

Page3.Visible = True;

Step3.Font.Bold = True;

ReviewFName.Text &= FirstName.Text;

ReviewMName.Text &= MiddleName.Text;

ReviewLName.Text &= LastName.Text;

ReviewEmail.Text &= Email.Text;

ReviewAddress.Text &= Address.Text;

ReviewCity.Text &= City.Text;

ReviewState.Text &= State.Text;

ReviewZip.Text &= Zip.Text;

break;

}

}

public void Previous_Click(object sender, System.EventArgs e)

{

switch(sender.Page.ID)

{
case "Page2":

Page2.Visible = False;

Step2.Font.Bold = False;

Page1.Visible = True;

Step1.Font.Bold = True;

break;

case "Page3":

Page3.Visible = False;

Step3.Font.Bold = False;

Page2.Visible = True;

Step2.Font.Bold = True;

break;
}

}

#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.Load += new System.EventHandler(this.Page_Load);

}

#endregion

}

}

----- Original Message -----
From: "wobbles" <no***************************@killspam.hotmail.co m>
Newsgroups: microsoft.public.dotnet.languages.csharp
Sent: Wednesday, January 07, 2004 3:42 PM
Subject: Re: VB to C sharp anyone can point out which is the equivalent

On Wed, 7 Jan 2004 15:06:04 -0600, "Hai Nguyen"
<ha******@neo.tamu.edu> wrote:
I'm learning C sharp and do not like vb much. I'm creatiing a wepage usingpanel to test myself. I tried to use these code below, which is written inVB, and to transform them to c sharp but I got hard time to understand vb
syntax. I don't know if anyone in here can point out which is the equivalentobject used in c sharp.

Translate these two lines to C sharp:

Sub Next_Click(Sender As Object, e As EventArgs)
Select Case Sender.Parent.ID
It will be something along the lines of:

private void next_click(object sender, System.EventArgs e) {

switch (sender.Parent.ID) {
case x:
//code
break;
case y:
//code
break;
case n:
//code
break;
default:
//code
break;
}

...

}

"Hai Nguyen" <ha******@neo.tamu.edu> wrote in message
news:uW**************@TK2MSFTNGP11.phx.gbl... I'm learning C sharp and do not like vb much. I'm creatiing a wepage using
panel to test myself. I tried to use these code below, which is written in
VB, and to transform them to c sharp but I got hard time to understand vb
syntax. I don't know if anyone in here can point out which is the equivalent object used in c sharp.

Translate these two lines to C sharp:

Sub Next_Click(Sender As Object, e As EventArgs)
Select Case Sender.Parent.ID
Thanks

<%@ Page Language="vb" %>
<html>
<head>
<script runat="server">
Sub Page_Load()
If Not IsPostBack Then
Step1.Font.Bold = True
End If
End Sub
Sub Next_Click(Sender As Object, e As EventArgs)
Select Case Sender.Parent.ID
Case "Page1"
Page1.Visible = False
Step1.Font.Bold = False
Page2.Visible = True
Step2.Font.Bold = True
Case "Page2"
Page2.Visible = False
Step2.Font.Bold = False
Page3.Visible = True
Step3.Font.Bold = True
ReviewFName.Text &= FirstName.Text
ReviewMName.Text &= MiddleName.Text
ReviewLName.Text &= LastName.Text
ReviewEmail.Text &= Email.Text
ReviewAddress.Text &= Address.Text
ReviewCity.Text &= City.Text
ReviewState.Text &= State.Text
ReviewZip.Text &= Zip.Text
End Select
End Sub

Sub Previous_Click(Sender As Object, e As EventArgs)
Select Case Sender.Parent.ID
Case "Page2"
Page2.Visible = False
Step2.Font.Bold = False
Page1.Visible = True
Step1.Font.Bold = True
Case "Page3"
Page3.Visible = False
Step3.Font.Bold = False
Page2.Visible = True
Step2.Font.Bold = True
End Select
End Sub
</script>
<style type="text/css">
div
{
background:silver;
width:400px;
border:2px outset;
margin:5px;
padding:5px;
}
</style>
</head>
<body>
<form runat="server">
<asp:label id="RegWiz" text="Registration Wizard" font-bold="true"
font-size="16" font-name="verdana" runat="server"/>
<br/>
<asp:label id="Step1" text="Step 1: Enter Personal Info"
font-name="verdana" runat="server"/>
<br/>
<asp:label id="Step2" text="Step 2: Enter Address Info"
font-name="verdana" runat="server"/>
<br/>
<asp:label id="Step3" text="Step 3: Review" font-name="verdana"
runat="server"/>
<br/>
<asp:panel id="Page1" runat="server">
<table align="center">
<tr>
<td>
<asp:label id="FirstNameLabel" text="First Name:"
runat="server"/>
</td>
<td>
<asp:textbox id="FirstName" runat="server"/>
</td>
</tr>
<tr>
<td>
<asp:label id="MiddleNameLabel" text="Middle Name:"
runat="server"/>
</td>
<td>
<asp:textbox id="MiddleName" runat="server"/>
</td>
</tr>
<tr>
<td>
<asp:label id="LastNameLabel" text="Last Name:"
runat="server"/>
</td>
<td>
<asp:textbox id="LastName" runat="server"/>
</td>
</tr>
<tr>
<td>
<asp:label id="EmailLabel" text="Email:" runat="server"/> </td>
<td>
<asp:textbox id="Email" runat="server"/>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<asp:button id="P1Previous" Text="Previous"
enabled="false" onclick="Previous_Click" runat="server"/>
<asp:button id="P1Next" Text="Next" onclick="Next_Click"
runat="server"/>
<input id="P1Reset" type="reset" runat="server"/>
</td>
</tr>
</table>
</asp:panel>
<asp:panel id="Page2" visible="false" runat="server">
<table align="center">
<tr>
<td>
<asp:label id="AddressLabel" text="Street Address:"
runat="server"/>
</td>
<td>
<asp:textbox id="Address" runat="server"/>
</td>
</tr>
<tr>
<td>
<asp:label id="CityLabel" text="City:" runat="server"/>
</td>
<td>
<asp:textbox id="City" runat="server"/>
</td>
</tr>
<tr>
<td>
<asp:label id="StateLabel" text="State:" runat="server"/> </td>
<td>
<asp:textbox id="State" runat="server"/>
</td>
</tr>
<tr>
<td>
<asp:label id="ZipLabel" text="Zip Code:" runat="server"/> </td>
<td>
<asp:textbox id="Zip" runat="server"/>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<asp:button id="P2Previous" Text="Previous"
onclick="Previous_Click" runat="server"/>
<asp:button id="P2Next" Text="Next" onclick="Next_Click"
runat="server"/>
<input id="P2Reset" type="reset" runat="server"/>
</td>
</tr>
</table>
</asp:panel>
<asp:panel id="Page3" visible="false" runat="server">
<table align="center">
<tr>
<td colspan="2">
<asp:label id="ReviewFName" text="First Name: "
runat="server"/>
</td>
</tr>
<tr>
<td colspan="2">
<asp:label id="ReviewMName" text="Middle Name: "
runat="server"/>
</td>
</tr>
<tr>
<td colspan="2">
<asp:label id="ReviewLName" text="Last Name: "
runat="server"/>
</td>
</tr>
<tr>
<td colspan="2">
<asp:label id="ReviewEmail" text="Email: "
runat="server"/>
</td>
</tr>
<tr>
<td colspan="2">
<asp:label id="ReviewAddress" text="Address: "
runat="server"/>
</td>
</tr>
<tr>
<td colspan="2">
<asp:label id="ReviewCity" text="City: " runat="server"/> </td>
</tr>
<tr>
<td colspan="2">
<asp:label id="ReviewState" text="State: "
runat="server"/>
</td>
</tr>
<tr>
<td colspan="2">
<asp:label id="ReviewZip" text="Zip: " runat="server"/>
</td>
</tr>
<tr>
<td colspan="2">
<asp:button id="P3Previous" Text="Previous"
onclick="Previous_Click" runat="server"/>
<asp:button id="P3Next" Text="Next" enabled="false"
onclick="Next_Click" runat="server"/>
<input id="P3Reset" type="reset" disabled="true"
runat="server"/>
</td>
</td>
</tr>
</table>
</asp:panel>
</form>
</body>
</html>

Nov 15 '05 #4
I've seen from your original post that Sender.Parent.ID seems to
return a string - which I missed originally.

So it needs to be:
case "Page 1":

rather than:
case x:
Hope you have better luck...


On Wed, 7 Jan 2004 20:39:44 -0600, "Hai Nguyen"
<ha******@neo.tamu.edu> wrote:
It did not work, would you please tell me more. This is the error it throws
after I used you way: I don't know if i have to import anything

public void Next_Click(object sender, System.EventArgs e)

{

switch(sender.Parent.ID)

....
}

the only object works I tried was this.Parent.ID but when I ran it it failed

please more insutructions
-------------------

code:

using System;

using System.Collections;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Web;

using System.Web.SessionState;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.HtmlControls;

namespace Energy

{

/// <summary>

/// Summary description for panel.

/// </summary>

public class panel : System.Web.UI.Page

{

protected System.Web.UI.WebControls.Label RegWiz;

protected System.Web.UI.WebControls.Label Step1;

protected System.Web.UI.WebControls.Label Step2;

protected System.Web.UI.WebControls.Label Step3;

protected System.Web.UI.WebControls.Label FirstNameLabel;

protected System.Web.UI.WebControls.TextBox FirstName;

protected System.Web.UI.WebControls.Label MiddleNameLabel;

protected System.Web.UI.WebControls.TextBox MiddleName;

protected System.Web.UI.WebControls.Label LastNameLabel;

protected System.Web.UI.WebControls.TextBox LastName;

protected System.Web.UI.WebControls.Label EmailLabel;

protected System.Web.UI.WebControls.TextBox Email;

protected System.Web.UI.WebControls.Button P1Previous;

protected System.Web.UI.WebControls.Button P1Next;

protected System.Web.UI.WebControls.Panel Page1;

protected System.Web.UI.WebControls.Label AddressLabel;

protected System.Web.UI.WebControls.TextBox Address;

protected System.Web.UI.WebControls.Label CityLabel;

protected System.Web.UI.WebControls.TextBox City;

protected System.Web.UI.WebControls.Label StateLabel;

protected System.Web.UI.WebControls.TextBox State;

protected System.Web.UI.WebControls.Label ZipLabel;

protected System.Web.UI.WebControls.TextBox Zip;

protected System.Web.UI.WebControls.Button P2Previous;

protected System.Web.UI.WebControls.Button P2Next;

protected System.Web.UI.WebControls.Panel Page2;

protected System.Web.UI.WebControls.Label ReviewFName;

protected System.Web.UI.WebControls.Label ReviewMName;

protected System.Web.UI.WebControls.Label ReviewLName;

protected System.Web.UI.WebControls.Label ReviewEmail;

protected System.Web.UI.WebControls.Label ReviewAddress;

protected System.Web.UI.WebControls.Label ReviewCity;

protected System.Web.UI.WebControls.Label ReviewState;

protected System.Web.UI.WebControls.Label ReviewZip;

protected System.Web.UI.WebControls.Button P3Previous;

protected System.Web.UI.WebControls.Button P3Next;

protected System.Web.UI.WebControls.Panel Page3;

protected System.Web.UI.HtmlControls.HtmlInputButton P1Reset;

protected System.Web.UI.HtmlControls.HtmlInputButton P2Reset;

protected System.Web.UI.HtmlControls.HtmlInputButton P3Reset;
private void Page_Load(object sender, System.EventArgs e)

{

if(!Page.IsPostBack)

{

Step1.Font.Bold = true;

}
}
public void Next_Click(object sender, System.EventArgs e)

{

switch(sender.Parent.ID)

{

case "Page1": Page1.Visible = False;

Step1.Font.Bold = False;

Page2.Visible = True;

Step2.Font.Bold = True;

break;

case "Page2": Page2.Visible = False;

Step2.Font.Bold = False;

Page3.Visible = True;

Step3.Font.Bold = True;

ReviewFName.Text &= FirstName.Text;

ReviewMName.Text &= MiddleName.Text;

ReviewLName.Text &= LastName.Text;

ReviewEmail.Text &= Email.Text;

ReviewAddress.Text &= Address.Text;

ReviewCity.Text &= City.Text;

ReviewState.Text &= State.Text;

ReviewZip.Text &= Zip.Text;

break;

}

}

public void Previous_Click(object sender, System.EventArgs e)

{

switch(sender.Page.ID)

{
case "Page2":

Page2.Visible = False;

Step2.Font.Bold = False;

Page1.Visible = True;

Step1.Font.Bold = True;

break;

case "Page3":

Page3.Visible = False;

Step3.Font.Bold = False;

Page2.Visible = True;

Step2.Font.Bold = True;

break;
}

}

#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.Load += new System.EventHandler(this.Page_Load);

}

#endregion

}

}

----- Original Message -----
From: "wobbles" <no***************************@killspam.hotmail.co m>
Newsgroups: microsoft.public.dotnet.languages.csharp
Sent: Wednesday, January 07, 2004 3:42 PM
Subject: Re: VB to C sharp anyone can point out which is the equivalent

On Wed, 7 Jan 2004 15:06:04 -0600, "Hai Nguyen"
<ha******@neo.tamu.edu> wrote:
>I'm learning C sharp and do not like vb much. I'm creatiing a wepageusing >panel to test myself. I tried to use these code below, which is writtenin >VB, and to transform them to c sharp but I got hard time to understand vb
>syntax. I don't know if anyone in here can point out which is theequivalent >object used in c sharp.
>
>Translate these two lines to C sharp:
>
> Sub Next_Click(Sender As Object, e As EventArgs)
> Select Case Sender.Parent.ID
>
>


It will be something along the lines of:

private void next_click(object sender, System.EventArgs e) {

switch (sender.Parent.ID) {
case x:
//code
break;
case y:
//code
break;
case n:
//code
break;
default:
//code
break;
}

...

}

"Hai Nguyen" <ha******@neo.tamu.edu> wrote in message
news:uW**************@TK2MSFTNGP11.phx.gbl...
I'm learning C sharp and do not like vb much. I'm creatiing a wepage using
panel to test myself. I tried to use these code below, which is written in
VB, and to transform them to c sharp but I got hard time to understand vb
syntax. I don't know if anyone in here can point out which is the

equivalent
object used in c sharp.

Translate these two lines to C sharp:

Sub Next_Click(Sender As Object, e As EventArgs)
Select Case Sender.Parent.ID
Thanks

<%@ Page Language="vb" %>
<html>
<head>
<script runat="server">
Sub Page_Load()
If Not IsPostBack Then
Step1.Font.Bold = True
End If
End Sub
Sub Next_Click(Sender As Object, e As EventArgs)
Select Case Sender.Parent.ID
Case "Page1"
Page1.Visible = False
Step1.Font.Bold = False
Page2.Visible = True
Step2.Font.Bold = True
Case "Page2"
Page2.Visible = False
Step2.Font.Bold = False
Page3.Visible = True
Step3.Font.Bold = True
ReviewFName.Text &= FirstName.Text
ReviewMName.Text &= MiddleName.Text
ReviewLName.Text &= LastName.Text
ReviewEmail.Text &= Email.Text
ReviewAddress.Text &= Address.Text
ReviewCity.Text &= City.Text
ReviewState.Text &= State.Text
ReviewZip.Text &= Zip.Text
End Select
End Sub

Sub Previous_Click(Sender As Object, e As EventArgs)
Select Case Sender.Parent.ID
Case "Page2"
Page2.Visible = False
Step2.Font.Bold = False
Page1.Visible = True
Step1.Font.Bold = True
Case "Page3"
Page3.Visible = False
Step3.Font.Bold = False
Page2.Visible = True
Step2.Font.Bold = True
End Select
End Sub
</script>
<style type="text/css">
div
{
background:silver;
width:400px;
border:2px outset;
margin:5px;
padding:5px;
}
</style>
</head>
<body>
<form runat="server">
<asp:label id="RegWiz" text="Registration Wizard" font-bold="true"
font-size="16" font-name="verdana" runat="server"/>
<br/>
<asp:label id="Step1" text="Step 1: Enter Personal Info"
font-name="verdana" runat="server"/>
<br/>
<asp:label id="Step2" text="Step 2: Enter Address Info"
font-name="verdana" runat="server"/>
<br/>
<asp:label id="Step3" text="Step 3: Review" font-name="verdana"
runat="server"/>
<br/>
<asp:panel id="Page1" runat="server">
<table align="center">
<tr>
<td>
<asp:label id="FirstNameLabel" text="First Name:"
runat="server"/>
</td>
<td>
<asp:textbox id="FirstName" runat="server"/>
</td>
</tr>
<tr>
<td>
<asp:label id="MiddleNameLabel" text="Middle Name:"
runat="server"/>
</td>
<td>
<asp:textbox id="MiddleName" runat="server"/>
</td>
</tr>
<tr>
<td>
<asp:label id="LastNameLabel" text="Last Name:"
runat="server"/>
</td>
<td>
<asp:textbox id="LastName" runat="server"/>
</td>
</tr>
<tr>
<td>
<asp:label id="EmailLabel" text="Email:"

runat="server"/>
</td>
<td>
<asp:textbox id="Email" runat="server"/>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<asp:button id="P1Previous" Text="Previous"
enabled="false" onclick="Previous_Click" runat="server"/>
<asp:button id="P1Next" Text="Next" onclick="Next_Click"
runat="server"/>
<input id="P1Reset" type="reset" runat="server"/>
</td>
</tr>
</table>
</asp:panel>
<asp:panel id="Page2" visible="false" runat="server">
<table align="center">
<tr>
<td>
<asp:label id="AddressLabel" text="Street Address:"
runat="server"/>
</td>
<td>
<asp:textbox id="Address" runat="server"/>
</td>
</tr>
<tr>
<td>
<asp:label id="CityLabel" text="City:" runat="server"/>
</td>
<td>
<asp:textbox id="City" runat="server"/>
</td>
</tr>
<tr>
<td>
<asp:label id="StateLabel" text="State:"

runat="server"/>
</td>
<td>
<asp:textbox id="State" runat="server"/>
</td>
</tr>
<tr>
<td>
<asp:label id="ZipLabel" text="Zip Code:"

runat="server"/>
</td>
<td>
<asp:textbox id="Zip" runat="server"/>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<asp:button id="P2Previous" Text="Previous"
onclick="Previous_Click" runat="server"/>
<asp:button id="P2Next" Text="Next" onclick="Next_Click"
runat="server"/>
<input id="P2Reset" type="reset" runat="server"/>
</td>
</tr>
</table>
</asp:panel>
<asp:panel id="Page3" visible="false" runat="server">
<table align="center">
<tr>
<td colspan="2">
<asp:label id="ReviewFName" text="First Name: "
runat="server"/>
</td>
</tr>
<tr>
<td colspan="2">
<asp:label id="ReviewMName" text="Middle Name: "
runat="server"/>
</td>
</tr>
<tr>
<td colspan="2">
<asp:label id="ReviewLName" text="Last Name: "
runat="server"/>
</td>
</tr>
<tr>
<td colspan="2">
<asp:label id="ReviewEmail" text="Email: "
runat="server"/>
</td>
</tr>
<tr>
<td colspan="2">
<asp:label id="ReviewAddress" text="Address: "
runat="server"/>
</td>
</tr>
<tr>
<td colspan="2">
<asp:label id="ReviewCity" text="City: "

runat="server"/>
</td>
</tr>
<tr>
<td colspan="2">
<asp:label id="ReviewState" text="State: "
runat="server"/>
</td>
</tr>
<tr>
<td colspan="2">
<asp:label id="ReviewZip" text="Zip: " runat="server"/>
</td>
</tr>
<tr>
<td colspan="2">
<asp:button id="P3Previous" Text="Previous"
onclick="Previous_Click" runat="server"/>
<asp:button id="P3Next" Text="Next" enabled="false"
onclick="Next_Click" runat="server"/>
<input id="P3Reset" type="reset" disabled="true"
runat="server"/>
</td>
</td>
</tr>
</table>
</asp:panel>
</form>
</body>
</html>


Nov 15 '05 #5

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

Similar topics

50
by: Jerry Sievers | last post by:
<venting> Fellow coders; I just get off the phone today with some clueless headhunter and after listing for her (very proudly I might add) my OS and dev tools platforms of choice; ...
9
by: Dragon | last post by:
Hi, I have 'some' experience in VB. I would like to learn C-Sharp and would like to know if the following book is any good or not. Thank you. Microsoft Visual C# .NET Step by Step - Version...
2
by: HishHish | last post by:
I have a Java code that I want to convert it to C-sharp in order to put it in my ASP.NET web application. I used the JLCA (Java Language Conversion Assistant) for conversion, but it gave me many...
23
by: arthur.mcginty | last post by:
Man I've grown tired with C#/.NET the last three days I spent trying to put a NULL value in a database. C# initializes all uninitialized properties to 0 (for numeric types) and didn't have until C#...
4
by: Hai Nguyen | last post by:
I'm learning C sharp and do not like vb much. I'm creatiing a wepage using panel to test myself. I tried to use these code below, which is written in VB, and to transform them to c sharp but I got...
2
by: vivekian | last post by:
Hi , I am a C Sharp newbie, and need to study its compiler internals as a part of my small project. Does Microsoft provide compiler details e.g. what kind of symbol table it uses etc ? I...
20
by: windandwaves | last post by:
Hi Folk I am a PHP programmer, but I like to learn c-sharp as it seems to be in hot demand around here. My questions are: - how does c-sharp relate to PHP - do you like c-sharp and its...
2
by: hilz | last post by:
Hi group, I am starting with C Sharp, and want to build a desktop application. I come from the Java world, where there are Rich Client Platforms that make life easier by providing most of the...
2
complete
by: complete | last post by:
What is the point of using set and get in C Sharp? It seems variables are used differently in this language than in C++. For some reason, you have to have a static variable defined like this:...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...

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.