473,769 Members | 2,081 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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("N ame") = "Gary" Then %>

<asp:RequiredFi eldValidator ID="GarysValida tion" ErrorMessage="G ary, you
have chosen the wrong option<BR>" ControlToValida te="Name" Display="Dynami c"
runat="server"> </asp:RequiredFie ldValidator>

<% End If %>

Thanks for any help,

Regards,

Gary.

Jan 21 '07 #1
10 2919
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.comwr ote in message news:Og******** *****@TK2MSFTNG P04.phx.gbl...
Hello,

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

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

<asp:RequiredFi eldValidator ID="GarysValida tion" ErrorMessage="G ary, you have chosen the wrong
option<BR>" ControlToValida te="Name" Display="Dynami c"
runat="server"> </asp:RequiredFie ldValidator>

<% End If %>

Thanks for any help,

Regards,

Gary.

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

<asp:RequiredFi eldValidator ID="GarysValida tion" ErrorMessage="G ary, you
have chosen the wrong option<BR>" ControlToValida te="Name" Display="Dynami c"
runat="server"> </asp:RequiredFie ldValidator>

<%
}
%>

--
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("N ame") = "Gary" Then %>

<asp:RequiredFi eldValidator ID="GarysValida tion" ErrorMessage="G ary, you
have chosen the wrong option<BR>" ControlToValida te="Name" Display="Dynami c"
runat="server"> </asp:RequiredFie ldValidator>

<% 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.comwr ote in message news:Og******** *****@TK2MSFTNG P04.phx.gbl...
Hello,

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

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

<asp:RequiredFi eldValidator ID="GarysValida tion" ErrorMessage="G ary, you have chosen the wrong
option<BR>" ControlToValida te="Name" Display="Dynami c"
runat="server"> </asp:RequiredFie ldValidator>

<% 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********@dis cussions.micros oft.comwrote in message
news:16******** *************** ***********@mic rosoft.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.comwr ote in message news:Og******** *****@TK2MSFTNG P04.phx.gbl...
Hello,

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

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

<asp:RequiredFi eldValidator ID="GarysValida tion" ErrorMessage="G ary, you have chosen the wrong
option<BR>" ControlToValida te="Name" Display="Dynami c"
runat="server"> </asp:RequiredFie ldValidator>

<% End If %>

Thanks for any help,

Regards,

Gary.



Jan 21 '07 #5
"Juan T. Llibre" <no***********@ nowhere.comwrot e in message
news:OU******** ********@TK2MSF TNGP02.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_In put" Runat="Server"/>

<asp:RequiredFi eldValidator Runat="Server"
ID="GarysValida tion"
ControlToValida te="Name"
ErrorMessage="G ary, you need to enter a value."
Display="Dynami c"
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.comwr ote in message news:ei******** ******@TK2MSFTN GP04.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.comwrot e:
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_In put" Runat="Server"/>

<asp:RequiredFi eldValidator Runat="Server"
ID="GarysValida tion"
ControlToValida te="Name"
ErrorMessage="G ary, you need to enter a value."
Display="Dynami c"
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.co mwrote in messagenews:ei* *************@T K2MSFTNGP04.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*******@gmai l.comwrote in message
news:11******** **************@ q2g2000cwa.goog legroups.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

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

Similar topics

3
4389
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 manipulation of the data (that are not allowed in EndNote). Anyone knows a simple tool (utility) that would allow that. By the way, I'm using Office 2002 (not XP/2003, which may have native XML features!).
4
1694
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); } set { txtVal1.Text = Convert.ToString(value); } }
4
1521
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 fuctions in new version) which puts to painful convervsion of code to aspx. But, is there a way to allow traditional asp to run on aspx page by codifying some form of 'transitional' declaration on the page in the same way one does for xhtml...
8
1999
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 development and then deploy the updated application to our QA server and then once tested to our production server. The application has a web.config file. The contents of the file (appsettings part) are different in all three environments because...
2
2286
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 at how difficult it has become to control a form, something that was so dead easy in ASP.
6
2341
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 populating a listbox with an array of very simple "Country" objects via a WebService. The Country class contains CountryID,TLDs and Name properties each of which have a getter and setter (I found that properties without
6
2230
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 so I have read up on the complexities of upgrade in the corporate environment. Also the need to carry out a full MDB audit to get rid of the redundancy etc etc
4
2495
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
1776
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 application, using "Add web reference..." and specifying some web reference name "MyName" Normally I would do:
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10049
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...
0
9865
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
8873
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5310
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3965
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3565
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.