Click here to Skip to main content
Click here to Skip to main content

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

, 12 Feb 2013 CPOL
Rate this:
Please Sign up or sign in to vote.
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.

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

The code:

[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)

Share

About the Author

KL431

United States United States
No Biography provided

Comments and Discussions

 
QuestionThought provoking PinmemberPaul Tait13-Feb-13 16:57 
QuestionTypescript!!!! PinmemberJohnGalt1712-Feb-13 10:09 
AnswerRe: Typescript!!!! PinmemberKL43112-Feb-13 20:53 

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

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

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.141223.1 | Last Updated 12 Feb 2013
Article Copyright 2013 by KL431
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid