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

Simple code - convert from VB.net to c#.net (web dev)

Hello,

Anyone know how to do the following in c# - using inline codeblocks?

<% If Request.Form("Name") = "Gary" Then %>

<asp:RequiredFieldValidator ID="GarysValidation" ErrorMessage="Gary, you
have chosen the wrong option<BR>" ControlToValidate="Name" Display="Dynamic"
runat="server"></asp:RequiredFieldValidator>

<% End If %>

Thanks for any help,

Regards,

Gary.

Jan 21 '07 #1
10 2877
There's many free online C#/VB.NET code converters you can use to do that.

Here's a few, in no particular order.
Check them out...and see which one you like best.

http://www.carlosag.net/Tools/CodeTr...r/default.aspx
http://www.dotnettaxi.com/Tools/Converter.aspx
http://www.developerfusion.co.uk/uti...btocsharp.aspx
http://www.eggheadcafe.com/articles/...converter.aspx

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Gary" <g@nospam.comwrote in message news:Og*************@TK2MSFTNGP04.phx.gbl...
Hello,

Anyone know how to do the following in c# - using inline codeblocks?

<% If Request.Form("Name") = "Gary" Then %>

<asp:RequiredFieldValidator ID="GarysValidation" ErrorMessage="Gary, you have chosen the wrong
option<BR>" ControlToValidate="Name" Display="Dynamic"
runat="server"></asp:RequiredFieldValidator>

<% End If %>

Thanks for any help,

Regards,

Gary.

Jan 21 '07 #2
(via Instant C#)
<%
if (Request.Form["Name"] == "Gary")
{
%>

<asp:RequiredFieldValidator ID="GarysValidation" ErrorMessage="Gary, you
have chosen the wrong option<BR>" ControlToValidate="Name" Display="Dynamic"
runat="server"></asp:RequiredFieldValidator>

<%
}
%>

--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
Instant Python: C#/VB to Python converter
"Gary" wrote:
Hello,

Anyone know how to do the following in c# - using inline codeblocks?

<% If Request.Form("Name") = "Gary" Then %>

<asp:RequiredFieldValidator ID="GarysValidation" ErrorMessage="Gary, you
have chosen the wrong option<BR>" ControlToValidate="Name" Display="Dynamic"
runat="server"></asp:RequiredFieldValidator>

<% End If %>

Thanks for any help,

Regards,

Gary.

Jan 21 '07 #3
The on-line converters won't convert in-line asp.net code Juan. (see my
other reply for the conversion).
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
Instant Python: C#/VB to Python converter
"Juan T. Llibre" wrote:
There's many free online C#/VB.NET code converters you can use to do that.

Here's a few, in no particular order.
Check them out...and see which one you like best.

http://www.carlosag.net/Tools/CodeTr...r/default.aspx
http://www.dotnettaxi.com/Tools/Converter.aspx
http://www.developerfusion.co.uk/uti...btocsharp.aspx
http://www.eggheadcafe.com/articles/...converter.aspx

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Gary" <g@nospam.comwrote in message news:Og*************@TK2MSFTNGP04.phx.gbl...
Hello,

Anyone know how to do the following in c# - using inline codeblocks?

<% If Request.Form("Name") = "Gary" Then %>

<asp:RequiredFieldValidator ID="GarysValidation" ErrorMessage="Gary, you have chosen the wrong
option<BR>" ControlToValidate="Name" Display="Dynamic"
runat="server"></asp:RequiredFieldValidator>

<% End If %>

Thanks for any help,

Regards,

Gary.


Jan 21 '07 #4
re:
The on-line converters won't convert in-line asp.net code Juan.
Maybe that should be a tip not to use ASP syntax in ASP.NET.
Would changing the control's visibility depending on the selected option be better ?

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"David Anton" <Da********@discussions.microsoft.comwrote in message
news:16**********************************@microsof t.com...
The on-line converters won't convert in-line asp.net code Juan. (see my
other reply for the conversion).
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
Instant Python: C#/VB to Python converter
"Juan T. Llibre" wrote:
>There's many free online C#/VB.NET code converters you can use to do that.

Here's a few, in no particular order.
Check them out...and see which one you like best.

http://www.carlosag.net/Tools/CodeTr...r/default.aspx
http://www.dotnettaxi.com/Tools/Converter.aspx
http://www.developerfusion.co.uk/uti...btocsharp.aspx
http://www.eggheadcafe.com/articles/...converter.aspx

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Gary" <g@nospam.comwrote in message news:Og*************@TK2MSFTNGP04.phx.gbl...
Hello,

Anyone know how to do the following in c# - using inline codeblocks?

<% If Request.Form("Name") = "Gary" Then %>

<asp:RequiredFieldValidator ID="GarysValidation" ErrorMessage="Gary, you have chosen the wrong
option<BR>" ControlToValidate="Name" Display="Dynamic"
runat="server"></asp:RequiredFieldValidator>

<% End If %>

Thanks for any help,

Regards,

Gary.



Jan 21 '07 #5
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:OU****************@TK2MSFTNGP02.phx.gbl...
>The on-line converters won't convert in-line asp.net code Juan.

Maybe that should be a tip not to use ASP syntax in ASP.NET.
Absolutely!
Jan 21 '07 #6
Maybe that should be a tip not to use ASP syntax in ASP.NET.
Would changing the control's visibility depending on the selected option
be better ?

Could you elaborate? You spotted I am a classic ASP coder, finding the
transition to .NET a challenge.

I do have a code behind file in place, and I am slowly reading about Life
Cycle etc, but at this moment I am unsure how best to approach this
particular task.

G.

Jan 21 '07 #7
re:
I am unsure how best to approach this particular task
Maybe adding some server code would help...

<script language = "VB" runat="server">

Sub Get_Input (Src As Object, Args As EventArgs)
Output.Text = "You entered '" & Name.Text & "'"
End Sub

</script>

<form Runat="Server">

<asp:TextBox id="Name" Runat="Server"/>

<asp:Button Text="Submit" OnClick="Get_Input" Runat="Server"/>

<asp:RequiredFieldValidator Runat="Server"
ID="GarysValidation"
ControlToValidate="Name"
ErrorMessage="Gary, you need to enter a value."
Display="Dynamic"
SetFocusOnError="True"/>

<asp:Label id="Output" Runat="Server"/>

</form>

I'm assuming that what you are aiming for is not having an empty textbox or,
if there is one, that the user can be informed without disruption.

Is that what you are aiming for ?

The above code will display the message "Gary, you need to enter a value."
if the textbox is empty, or will display whatever the user wrote into the Name textbox.


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Gary" <g@nospam.comwrote in message news:ei**************@TK2MSFTNGP04.phx.gbl...
>Maybe that should be a tip not to use ASP syntax in ASP.NET.
Would changing the control's visibility depending on the selected option be better ?


Could you elaborate? You spotted I am a classic ASP coder, finding the transition to .NET a
challenge.

I do have a code behind file in place, and I am slowly reading about Life Cycle etc, but at this
moment I am unsure how best to approach this particular task.

G.

Jan 21 '07 #8
On 1月22æ—¥, 上åˆ7時20分, "Juan T.Llibre" <nomailrepl...@nowhere.comwrote:
re:
I am unsure how best to approach this particular task

Maybe adding some server code would help...

<script language = "VB" runat="server">

Sub Get_Input (Src As Object, Args As EventArgs)
Output.Text = "You entered '" & Name.Text & "'"
End Sub

</script>

<form Runat="Server">

<asp:TextBox id="Name" Runat="Server"/>

<asp:Button Text="Submit" OnClick="Get_Input" Runat="Server"/>

<asp:RequiredFieldValidator Runat="Server"
ID="GarysValidation"
ControlToValidate="Name"
ErrorMessage="Gary, you need to enter a value."
Display="Dynamic"
SetFocusOnError="True"/>

<asp:Label id="Output" Runat="Server"/>

</form>

I'm assuming that what you are aiming for is not having an empty textbox or,
if there is one, that the user can be informed without disruption.

Is that what you are aiming for ?

The above code will display the message "Gary, you need to enter a value."
if the textbox is empty, or will display whatever the user wrote into theName textbox.

Juan T. Llibre, asp.net MVP
asp.net faq :http://asp.net.do/faq/
foros de asp.net, en español :http://asp.net.do/foros/
===================================

"Gary" <g...@nospam.comwrote in messagenews:ei**************@TK2MSFTNGP04.phx.gbl. ..
Maybe that should be a tip not to use ASP syntax in ASP.NET.
Would changing the control's visibility depending on the selected option be better ?
Could you elaborate? You spotted I am a classic ASP coder, finding thetransition to .NET a
challenge.
I do have a code behind file in place, and I am slowly reading about Life Cycle etc, but at this
moment I am unsure how best to approach this particular task.
G.

I would like to ask that, if i have a VB.net file, is there any free
tools for me to convert it into C#.net?

Thx a lot!!!

Feb 6 '07 #9
<yy*******@gmail.comwrote in message
news:11**********************@q2g2000cwa.googlegro ups.com...
I would like to ask that, if i have a VB.net file, is there any free
tools for me to convert it into C#.net?
Loads of 'em - do a Google search...
Feb 6 '07 #10
Here's three free online tools:

http://www.developerfusion.co.uk/uti...btocsharp.aspx

http://www.carlosag.net/Tools/CodeTr...r/default.aspx

http://www.dotnettaxi.com/Tools/Converter.aspx

And a free IDE which has a converter:
http://www.icsharpcode.net/OpenSource/SD/Download/


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
<yy*******@gmail.comwrote in message news:11**********************@q2g2000cwa.googlegro ups.com...

I would like to ask that, if i have a VB.net file, is there any free
tools for me to convert it into C#.net?

Thx a lot!!!
Feb 6 '07 #11

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

Similar topics

3
by: Fabrice Cavarretta | last post by:
I am using a specialized database software (for bibliography: EndNote) that does export in XML. I would like to be able to read that into a simple software, like Excel or Access, in order to do...
4
by: Chris | last post by:
Hi, I have 2 textboxes (txtVal1, txtVal2) in a WebUserControl (WebCalcUserControl) for which I write public properties : public int Value1 { get { return Convert.ToInt32(txtVal1.Text); }...
4
by: | last post by:
I have used my first aspx page on our site to utitlize the Ad Rotator component. However, I note that my traditional asp 3.0 code generations compilation errros (eg Let and Set not allowed in...
8
by: Robert | last post by:
I have what I think should be a pretty common scenario in a corporate environment. I have a web app and three environments on three servers: Development, QA and Production. We develop in...
2
by: Eniac | last post by:
*argh* ... *pull hairs* I've recently started developing from ASP to ASP.NET The switch was fairly smooth since i had done some VB.net before ... then came...FORMS! :) I find it astounding...
6
by: Paul | last post by:
Hi All, Framework 1.1 listbox control unable to DataBind I've been googling for an answer to this query that appears quite a lot, but none, it seem, answers my problem directly. I am...
6
by: tombsy | last post by:
Hello Group. I work for a company who is about to embark on a long awaited Office upgrade from Office 97 to Office XP. Office XP comes with Access 2002. I am an accomplished Access developer...
4
by: jiatiejun | last post by:
I want to convert a path from ~/xxx/xxx.gif to 'http://xxxxxxx/xxx/xxx.gif' how to convert it? thanks btw: the convert function allow
5
by: Nightfall | last post by:
Dear friends, consider the following scenario, in Visual Studio 2005 and C# - I create a ASP.NET web service ("server") with a class MyClass and a WebMethod SomeMethod() - I create a client...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.