473,782 Members | 2,423 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(Send er As Object, e As EventArgs)
Select Case Sender.Parent.I D
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(Send er As Object, e As EventArgs)
Select Case Sender.Parent.I D
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.Tex t &= FirstName.Text
ReviewMName.Tex t &= MiddleName.Text
ReviewLName.Tex t &= LastName.Text
ReviewEmail.Tex t &= Email.Text
ReviewAddress.T ext &= Address.Text
ReviewCity.Text &= City.Text
ReviewState.Tex t &= State.Text
ReviewZip.Text &= Zip.Text
End Select
End Sub

Sub Previous_Click( Sender As Object, e As EventArgs)
Select Case Sender.Parent.I D
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:silv er;
width:400px;
border:2px outset;
margin:5px;
padding:5px;
}
</style>
</head>
<body>
<form runat="server">
<asp:label id="RegWiz" text="Registrat ion 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="FirstNameLa bel" text="First Name:"
runat="server"/>
</td>
<td>
<asp:textbox id="FirstName" runat="server"/>
</td>
</tr>
<tr>
<td>
<asp:label id="MiddleNameL abel" text="Middle Name:"
runat="server"/>
</td>
<td>
<asp:textbox id="MiddleName " runat="server"/>
</td>
</tr>
<tr>
<td>
<asp:label id="LastNameLab el" 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="Previo us_Click" runat="server"/>
<asp:button id="P1Next" Text="Next" onclick="Next_C lick"
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="AddressLabe l" 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="Previo us_Click" runat="server"/>
<asp:button id="P2Next" Text="Next" onclick="Next_C lick"
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="ReviewAddre ss" 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="Previo us_Click" runat="server"/>
<asp:button id="P3Next" Text="Next" enabled="false"
onclick="Next_C lick" runat="server"/>
<input id="P3Reset" type="reset" disabled="true"
runat="server"/>
</td>
</td>
</tr>
</table>
</asp:panel>
</form>
</body>
</html>

Nov 18 '05 #1
4 1164
VB Lines;

Sub Next_Click(Send er As Object, e As EventArgs)
Select Case Sender.Parent.I D

C# translation with some additional:

void Next_Click(obje ct sender, EventArgs e)
{
swith (Sender.Parent. ID)
{
case "youridstri ng" :
// do something
break;
default :
// provide a default behavior
break;
}
// other code in the function.
}
"Hai Nguyen" <ha******@neo.t amu.edu> wrote in message
news:%2******** ********@TK2MSF TNGP10.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(Send er As Object, e As EventArgs)
Select Case Sender.Parent.I D
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(Send er As Object, e As EventArgs)
Select Case Sender.Parent.I D
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.Tex t &= FirstName.Text
ReviewMName.Tex t &= MiddleName.Text
ReviewLName.Tex t &= LastName.Text
ReviewEmail.Tex t &= Email.Text
ReviewAddress.T ext &= Address.Text
ReviewCity.Text &= City.Text
ReviewState.Tex t &= State.Text
ReviewZip.Text &= Zip.Text
End Select
End Sub

Sub Previous_Click( Sender As Object, e As EventArgs)
Select Case Sender.Parent.I D
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:silv er;
width:400px;
border:2px outset;
margin:5px;
padding:5px;
}
</style>
</head>
<body>
<form runat="server">
<asp:label id="RegWiz" text="Registrat ion 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="FirstNameLa bel" text="First Name:"
runat="server"/>
</td>
<td>
<asp:textbox id="FirstName" runat="server"/>
</td>
</tr>
<tr>
<td>
<asp:label id="MiddleNameL abel" text="Middle Name:"
runat="server"/>
</td>
<td>
<asp:textbox id="MiddleName " runat="server"/>
</td>
</tr>
<tr>
<td>
<asp:label id="LastNameLab el" 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="Previo us_Click" runat="server"/>
<asp:button id="P1Next" Text="Next" onclick="Next_C lick"
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="AddressLabe l" 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="Previo us_Click" runat="server"/>
<asp:button id="P2Next" Text="Next" onclick="Next_C lick"
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="ReviewAddre ss" 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="Previo us_Click" runat="server"/>
<asp:button id="P3Next" Text="Next" enabled="false"
onclick="Next_C lick" runat="server"/>
<input id="P3Reset" type="reset" disabled="true"
runat="server"/>
</td>
</td>
</tr>
</table>
</asp:panel>
</form>
</body>
</html>

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

Sub Next_Click(Send er As Object, e As EventArgs)
Select Case Sender.Parent.I D
private void Next_Click(obje ct Sender, EventArgs e)
{
switch (Sender.ParentI D)
{
}
}

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Hai Nguyen" <ha******@neo.t amu.edu> wrote in message
news:#T******** ******@TK2MSFTN GP10.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(Send er As Object, e As EventArgs)
Select Case Sender.Parent.I D
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(Send er As Object, e As EventArgs)
Select Case Sender.Parent.I D
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.Tex t &= FirstName.Text
ReviewMName.Tex t &= MiddleName.Text
ReviewLName.Tex t &= LastName.Text
ReviewEmail.Tex t &= Email.Text
ReviewAddress.T ext &= Address.Text
ReviewCity.Text &= City.Text
ReviewState.Tex t &= State.Text
ReviewZip.Text &= Zip.Text
End Select
End Sub

Sub Previous_Click( Sender As Object, e As EventArgs)
Select Case Sender.Parent.I D
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:silv er;
width:400px;
border:2px outset;
margin:5px;
padding:5px;
}
</style>
</head>
<body>
<form runat="server">
<asp:label id="RegWiz" text="Registrat ion 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="FirstNameLa bel" text="First Name:"
runat="server"/>
</td>
<td>
<asp:textbox id="FirstName" runat="server"/>
</td>
</tr>
<tr>
<td>
<asp:label id="MiddleNameL abel" text="Middle Name:"
runat="server"/>
</td>
<td>
<asp:textbox id="MiddleName " runat="server"/>
</td>
</tr>
<tr>
<td>
<asp:label id="LastNameLab el" 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="Previo us_Click" runat="server"/>
<asp:button id="P1Next" Text="Next" onclick="Next_C lick"
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="AddressLabe l" 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="Previo us_Click" runat="server"/>
<asp:button id="P2Next" Text="Next" onclick="Next_C lick"
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="ReviewAddre ss" 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="Previo us_Click" runat="server"/>
<asp:button id="P3Next" Text="Next" enabled="false"
onclick="Next_C lick" runat="server"/>
<input id="P3Reset" type="reset" disabled="true"
runat="server"/>
</td>
</td>
</tr>
</table>
</asp:panel>
</form>
</body>
</html>

Nov 18 '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(obje ct sender, System.EventArg s e)

{

switch(sender.P arent.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.Collecti ons;

using System.Componen tModel;

using System.Data;

using System.Drawing;

using System.Web;

using System.Web.Sess ionState;

using System.Web.UI;

using System.Web.UI.W ebControls;

using System.Web.UI.H tmlControls;

namespace Energy

{

/// <summary>

/// Summary description for panel.

/// </summary>

public class panel : System.Web.UI.P age

{

protected System.Web.UI.W ebControls.Labe l RegWiz;

protected System.Web.UI.W ebControls.Labe l Step1;

protected System.Web.UI.W ebControls.Labe l Step2;

protected System.Web.UI.W ebControls.Labe l Step3;

protected System.Web.UI.W ebControls.Labe l FirstNameLabel;

protected System.Web.UI.W ebControls.Text Box FirstName;

protected System.Web.UI.W ebControls.Labe l MiddleNameLabel ;

protected System.Web.UI.W ebControls.Text Box MiddleName;

protected System.Web.UI.W ebControls.Labe l LastNameLabel;

protected System.Web.UI.W ebControls.Text Box LastName;

protected System.Web.UI.W ebControls.Labe l EmailLabel;

protected System.Web.UI.W ebControls.Text Box Email;

protected System.Web.UI.W ebControls.Butt on P1Previous;

protected System.Web.UI.W ebControls.Butt on P1Next;

protected System.Web.UI.W ebControls.Pane l Page1;

protected System.Web.UI.W ebControls.Labe l AddressLabel;

protected System.Web.UI.W ebControls.Text Box Address;

protected System.Web.UI.W ebControls.Labe l CityLabel;

protected System.Web.UI.W ebControls.Text Box City;

protected System.Web.UI.W ebControls.Labe l StateLabel;

protected System.Web.UI.W ebControls.Text Box State;

protected System.Web.UI.W ebControls.Labe l ZipLabel;

protected System.Web.UI.W ebControls.Text Box Zip;

protected System.Web.UI.W ebControls.Butt on P2Previous;

protected System.Web.UI.W ebControls.Butt on P2Next;

protected System.Web.UI.W ebControls.Pane l Page2;

protected System.Web.UI.W ebControls.Labe l ReviewFName;

protected System.Web.UI.W ebControls.Labe l ReviewMName;

protected System.Web.UI.W ebControls.Labe l ReviewLName;

protected System.Web.UI.W ebControls.Labe l ReviewEmail;

protected System.Web.UI.W ebControls.Labe l ReviewAddress;

protected System.Web.UI.W ebControls.Labe l ReviewCity;

protected System.Web.UI.W ebControls.Labe l ReviewState;

protected System.Web.UI.W ebControls.Labe l ReviewZip;

protected System.Web.UI.W ebControls.Butt on P3Previous;

protected System.Web.UI.W ebControls.Butt on P3Next;

protected System.Web.UI.W ebControls.Pane l Page3;

protected System.Web.UI.H tmlControls.Htm lInputButton P1Reset;

protected System.Web.UI.H tmlControls.Htm lInputButton P2Reset;

protected System.Web.UI.H tmlControls.Htm lInputButton P3Reset;
private void Page_Load(objec t sender, System.EventArg s e)

{

if(!Page.IsPost Back)

{

Step1.Font.Bold = true;

}
}
public void Next_Click(obje ct sender, System.EventArg s e)

{

switch(sender.P arent.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.Tex t &= FirstName.Text;

ReviewMName.Tex t &= MiddleName.Text ;

ReviewLName.Tex t &= LastName.Text;

ReviewEmail.Tex t &= Email.Text;

ReviewAddress.T ext &= Address.Text;

ReviewCity.Text &= City.Text;

ReviewState.Tex t &= State.Text;

ReviewZip.Text &= Zip.Text;

break;

}

}

public void Previous_Click( object sender, System.EventArg s e)

{

switch(sender.P age.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(EventArg s e)

{

//

// CODEGEN: This call is required by the ASP.NET Web Form Designer.

//

InitializeCompo nent();

base.OnInit(e);

}
/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeCompo nent()

{

this.Load += new System.EventHan dler(this.Page_ Load);

}

#endregion

}

}

----- Original Message -----
From: "wobbles" <no************ *************** @killspam.hotma il.com>
Newsgroups: microsoft.publi c.dotnet.langua ges.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.t amu.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(Send er As Object, e As EventArgs)
Select Case Sender.Parent.I D
It will be something along the lines of:

private void next_click(obje ct sender, System.EventArg s e) {

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

...

}

"Hai Nguyen" <ha******@neo.t amu.edu> wrote in message
news:%2******** ********@TK2MSF TNGP10.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(Send er As Object, e As EventArgs)
Select Case Sender.Parent.I D
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(Send er As Object, e As EventArgs)
Select Case Sender.Parent.I D
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.Tex t &= FirstName.Text
ReviewMName.Tex t &= MiddleName.Text
ReviewLName.Tex t &= LastName.Text
ReviewEmail.Tex t &= Email.Text
ReviewAddress.T ext &= Address.Text
ReviewCity.Text &= City.Text
ReviewState.Tex t &= State.Text
ReviewZip.Text &= Zip.Text
End Select
End Sub

Sub Previous_Click( Sender As Object, e As EventArgs)
Select Case Sender.Parent.I D
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:silv er;
width:400px;
border:2px outset;
margin:5px;
padding:5px;
}
</style>
</head>
<body>
<form runat="server">
<asp:label id="RegWiz" text="Registrat ion 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="FirstNameLa bel" text="First Name:"
runat="server"/>
</td>
<td>
<asp:textbox id="FirstName" runat="server"/>
</td>
</tr>
<tr>
<td>
<asp:label id="MiddleNameL abel" text="Middle Name:"
runat="server"/>
</td>
<td>
<asp:textbox id="MiddleName " runat="server"/>
</td>
</tr>
<tr>
<td>
<asp:label id="LastNameLab el" 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="Previo us_Click" runat="server"/>
<asp:button id="P1Next" Text="Next" onclick="Next_C lick"
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="AddressLabe l" 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="Previo us_Click" runat="server"/>
<asp:button id="P2Next" Text="Next" onclick="Next_C lick"
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="ReviewAddre ss" 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="Previo us_Click" runat="server"/>
<asp:button id="P3Next" Text="Next" enabled="false"
onclick="Next_C lick" runat="server"/>
<input id="P3Reset" type="reset" disabled="true"
runat="server"/>
</td>
</td>
</tr>
</table>
</asp:panel>
</form>
</body>
</html>

Nov 18 '05 #4
I figured out, this is how i fixed it

switch(((Button )sender).Parent .ID) instead of switch(sender.P arent.ID)


"Hai Nguyen" <ha******@neo.t amu.edu> wrote in message
news:%2******** ********@TK2MSF TNGP10.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(Send er As Object, e As EventArgs)
Select Case Sender.Parent.I D
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(Send er As Object, e As EventArgs)
Select Case Sender.Parent.I D
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.Tex t &= FirstName.Text
ReviewMName.Tex t &= MiddleName.Text
ReviewLName.Tex t &= LastName.Text
ReviewEmail.Tex t &= Email.Text
ReviewAddress.T ext &= Address.Text
ReviewCity.Text &= City.Text
ReviewState.Tex t &= State.Text
ReviewZip.Text &= Zip.Text
End Select
End Sub

Sub Previous_Click( Sender As Object, e As EventArgs)
Select Case Sender.Parent.I D
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:silv er;
width:400px;
border:2px outset;
margin:5px;
padding:5px;
}
</style>
</head>
<body>
<form runat="server">
<asp:label id="RegWiz" text="Registrat ion 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="FirstNameLa bel" text="First Name:"
runat="server"/>
</td>
<td>
<asp:textbox id="FirstName" runat="server"/>
</td>
</tr>
<tr>
<td>
<asp:label id="MiddleNameL abel" text="Middle Name:"
runat="server"/>
</td>
<td>
<asp:textbox id="MiddleName " runat="server"/>
</td>
</tr>
<tr>
<td>
<asp:label id="LastNameLab el" 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="Previo us_Click" runat="server"/>
<asp:button id="P1Next" Text="Next" onclick="Next_C lick"
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="AddressLabe l" 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="Previo us_Click" runat="server"/>
<asp:button id="P2Next" Text="Next" onclick="Next_C lick"
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="ReviewAddre ss" 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="Previo us_Click" runat="server"/>
<asp:button id="P3Next" Text="Next" enabled="false"
onclick="Next_C lick" runat="server"/>
<input id="P3Reset" type="reset" disabled="true"
runat="server"/>
</td>
</td>
</tr>
</table>
</asp:panel>
</form>
</body>
</html>

Nov 18 '05 #5

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

Similar topics

50
4324
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; Linux/Apache/Postgres/PHP I get a few moments of silence and she mentiones to me some new wizzy
4
2512
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 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...
9
2355
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 2003 by John Sharp and Jon Jagger ISBN:0735619093
2
3900
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 errors indicating that there are not matches in .NET for those Java classes!! The Java code is: ***************************************************************** import java.util.Properties; import javax.mail.*;
23
2314
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# 2 any concept of NULLs. I keep wondering how you guys built all these .NET apps on the top of a database. And guess what? If you fail to initialize a DateTime (maybe because you just don't want to touch it!) you get it infact initialized to...
2
2049
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 believe there is an equivalent Linux implementation - Mono available . Would looking it up help since its open source ? Any pointers to links would be a big help. Thanks in advance,
20
2624
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 cousins - are there better things to do then c-sharp? Thanks a million
2
8929
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 standard services needed by a desktop application. Examples are the NetBeans Platform, and the Eclipse RCP among others. Is there such a thing in the C Sharp/.Net world? Or do I have to build my application from the ground up? Thanks for any help.
3
1396
by: Laoballer | last post by:
Hello all, I'm new to C sharp and am starting a project where I have to bring in historic weather data into a mysql database. The weather data can be retrieved via anonymous ftp spanning multiple files. What I would like to be able to do is create a C# application that will ftp into the server and download the necessary files automatically. Does anyone have any suggestions on how to do this and point me in the right direction. Thanks
2
28237
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: public static uint Somenum { set { m_somenum = value; } get { return m_somenum; } } and prior to this declaration, you need to have this: public uint m_sumenum;
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10081
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
9946
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
8968
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...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6735
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
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4044
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
3
2875
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.