Click here to Skip to main content
15,886,072 members
Articles / Programming Languages / C#
Tip/Trick

What I believe is the 'best framework' for website development, or maybe MVC 5?

Rate me:
Please Sign up or sign in to vote.
4.00/5 (1 vote)
12 Feb 2013CPOL2 min read 9.5K   3   3
I want to propose a new method which drops out JavaScript, CoffeScript, and all other pesky non-C# code you have to write.

What I believe is the 'best framework' for website development, or maybe MVC 5 ?

Recently, I've started to be more interested in web development. I've played around with PHP, quickly shifted to ASP.NET MVC. I like the "out of the box" defaults there, so there are minimal settings required to create a "nice" website. I like the automatic parameter mapper too.

I also started playing with Entity Framework, using its LINQ to SQL feature. I like that you don't have to "leave" C# when doing database queries.

What I don't like is the usage of JavaScript. I believe it is a redundant, old, bad language we should use "only if we have to". When you write an ASP.NET MVC app, you still have to use jQuery callbacks for AJAX, parsing the JSON and writing too much boring code.

I want to propose a new method which drops out JavaScript, CoffeScript, and all other pesky non-C# code you have to write.

We all know you have to write both client-side and server-side code. But why make the code different? Lets say I want to manipulate the DOM. In WebForms, you could do it like in a method similar to WinForms - sending out a new page with the manipulated DOM. I'm also pretty sure you could do it with Ajax instead, which is even nicer. But if you want to manipulate it in client side, you have to write JavaScript, which might break the WebForms structure. I don't like that.

Currently, we have technologies which converts .NET (or C#) to JavaScript, which also implements the whole JavaScript "browser" library, including jQuery, hard-coded. So now, you write C# which gets JSON from a handler, parses that JSON in C#, and manipulates the DOM accordingly. You have to manually write C# code which is equivalent to $(id).html(...) or such. Basically, you didn't do much.

Let's try making a standard library for the DOM, which will include all features, like WebForms has, which will work both server side and client side. It's basically taking both positive sides from WebForms AND MVC. You will write regular HTML websites, using the Razor syntax. If you, for example, write a Single Page App, and you want some code to run locally, you mark it with [ClientSide], and if you want some code to access the database and such, you mark it with [ServerSide]. Then, if you add an event listener to an OnClick event, it will automatically know whether to simply execute the client side JavaScript (converted from C#) or, using AJAX, call the server (asynchronously of course), and do what its response tells you to do (the server might return JavaScript to be eval'd). This way, both server side and client side manipulate the DOM using the same codebase, but in different methods completely.

XML
<input id="SearchButton" type="button" value="Hey!" />
<input id="SearchTB" type="text" />
<table id="Results"></table>

The code:

C#
[ClientSide]
public void DoSomething()
{
 var button = Buttons.SearchButton;
 button.Style.Left += 10;
 button.Value = "Search";
 button.OnClick += new EventHandler(Search);
}

[ServerSide]
public void Search()
{
 var text = TextBoxes.SearchTB.Value;
 var results = from entry in DB.Entries
      where entry.Name.Contains(text)
      select entry;
 Tables.Results.AddRange(results);
 //an "entry" has: Name, Date, Location ....
 //automatically converted to the columns & rows in the table
}

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionThought provoking Pin
Paul Tait13-Feb-13 15:57
Paul Tait13-Feb-13 15:57 
QuestionTypescript!!!! Pin
JohnGalt1712-Feb-13 9:09
JohnGalt1712-Feb-13 9:09 
AnswerRe: Typescript!!!! Pin
KL43112-Feb-13 19:53
KL43112-Feb-13 19:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.