0

I want to know that whether it is possible to use C# in a webpage developed with HTML. I'm new to web developing, but not to .NET. Below is my code:

<script type="text/c#">
    System.string foo = "Hello world!";
    public void Check(string username, string pass) {

    }
</script>

I can't download Visual Studio for Web.

2
  • 1
    Not directly but you can use ASP.NET to bring C# into the web world. Commented Jul 4, 2015 at 6:14
  • Short answer: not on the client-side, no. Long answer: not generally (excepting cross compilation to js, or Silverlight). You should probably look at typescript, too. Commented Jul 4, 2015 at 6:25

2 Answers 2

1

C# is a type-safe object-oriented "backend" and rather heavy language which does not belong on your frontend (html pages).

If you wish to use C# to manipulate your data, you should look into general ASP.NET structure.

That being said there are various ways to introduce select C# code into your views (such as Razor), however if you wish to manipulate simple objects client side your best bet is Javascript, which you can ask stackoverflow questions about here.

Your code would translate to:

var foo = "Hello world!";
function Check(string username, string pass) {
    //do stuff
}
Sign up to request clarification or add additional context in comments.

Comments

0

If you say you are not new to .NET then you might be aware of the server tags. These are used to evaluate or execute csharp statements. If you are using and aspx page you can execute or write a csharp code as follow in the aspx page:

<% --- your code--- %>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.