ASP.NET MVC and HTML5 - html

I have been looking into HTML5 and I am really excited to try it out.
As a framework I would like to use ASP.NET MVC, but I am unsure how it works with HTML5.
Are there (i know there are, but not sure if they are good) any good HTML5 toolkits for ASP.NET MVC? Basically i would like some pointers where to start with creating a page with rich HTML5 controls using MVC + some pros and cons from your experience.
Anyway I am willing to ditch PHP and start with MVC if the HTML support is there... I have C# skills and I understand the MVC pattern.
With best regards, no9.

MVC and HTML 5 don't really have anything to do with each other so you can use any framework you want, its all about the program.
And Visual Studio 2012 supports HTML 5 you should install a extension for VS called "Web Essentials 2012" for the best support for HTML 5.
For a good startup you can also check html5boilerplate out.
I hope this helps getting you started.

I wrote an HTML5 toolkit for ASP.NET MVC that you simply add to your project that will give you the functionality that you need.
Once you have added the library to your project, you can use it in your View like so:
#Html.Html5TextBox("txtOne", InputType.Color)
Which will return a textbox element that looks like:
<input type="color" id="txtOne" name="txtOne">
There is loads of support for many other HTML5 input types - for more information, check out the blog post.

Related

Need best MVC 4 Web API Grid

Could any one please suggest the best MVC4 WEB API Grid ?
Right now we are using Mustache templates to display Data.
Current App: MVC 4 Web API, C#.Net, Visual Studio 2012, Mustache templates
Client wants Mustache templates to be replaced with nice grid with all the search and sorting features.
Datatables.net provides a lot of functionality and is widely used.
I've had success using jqgrid - a lot of functionality and demos for mvc -
http://www.trirand.com/blog/
Datatables, jqgrid, kendoUI etc.. they will in the long term cause you extreme frustration and unhappiness.
Best thing to do is really make data LOOK like a grid, you can have complete control and really understand what is going on and do sorting and paging etc.. Use Bootstrap for CSS and make ajax calls to Web Api.
Angular is really nice, but you can start without Angular. I've been on 40 projects in which the 3 I mentioned caused a lot of headaches for many people including myself.

Is HTML5 compatible with C#?

I am having trouble finding a clear answer on this one. I have an ASP.NET 4.0 Silverlight app, but recently a ton of users are complaining about not being able to use the site on mobile devices and Linux distro's. The app is built on MVVM architecture, and thus we are considering changing the UI to alleviate the complaints. We are leaning toward HTML5, but I'm not sure if this is even technically possible with ASP.NET 4.0. I've seen some posts saying that HTML5 only works with javascript code behinds, and that with ASP.NET 4.5 HTML5 support will be added. Am I understanding this correctly? Maybe it would make more sense to just go with an ASPX UI, what are the advantages of HTML5 over .ASPX? Any help is appreciated.
HTML5 is a set of client-side technologies.
ASP.Net is a server-side technology.
They have nothing to do with each-other.
However, it will be easier in ASP.Net MVC.
You would replace what is currently in the Silverlight plugin that runs in the users browser with some html and javascript instead.
It is not technically possible with ASP.NET 4.0. ASP.NET certainly needs the upgrade in order to handle any HTML5-producing code behind or 'plug-ins.' I second the notion of ASP.NET MVC. Also it seems you are comparing a car to gasoline when you ask the advantages of HTML5 over ASPX.
HTML5 works in conjunction with Javascript on the client side. You can still use ASP.NET to process data and deliver content server side. Here are some quick links.
http://visualstudiomagazine.com/articles/2011/09/01/pfcov_html5.aspx
http://mvchtml5.codeplex.com/ (I know it's mvc, but it might be helpful regardless.)
I'm really surprised where somebody telling that all the C# code of the ViewModel and xaml code behind replace with Javascript . Is is possible ? Where in MVVM architecture code are huge and all are responsible for higher task(like communicate with service layer or database).
Is it possible to convert all C# code in JavaScript.
Even I have seen if a JavaScript function take over 25 lines than it becomes some clumsy fro developer to understand . Simple or small functionality can easy develop with javaScript .
C# is very standard and object oriented language ,to develop LOB it has great role but Javascript is not too much .
I'm think Using asp.net mvc is nice to use HTML5 , see we just need to change UI page look using HTML5 but rest of application functionality should remain Same .

ASP.Net and HTML5

I need to develop a web application, i have two choices
mvc3 straight forward implementation
using HTML5
i want to know whether HTML5 can be used as part of .net web application architecture or not?
Reasons:
there is no official support of HTML5 server controls like
Now IE 9 was launched but how good it supports HTML5
I found in internet that there is installation for HTML5 helper, but how reliabale it is?
I need guidance on the HTML5 and .net and if any tutorials in this combination.
Thanks in advance
Standards are based on implementation, not invention. If Microsoft wants to wait till HTML5 spec is finished, they will be waiting a long time. Meanwhile, modern browsers have implemented large portions of the spec and are moving forward.
With that in mind, how can one expect ASP.NET to contain elements of HTML5 and related technologies if Microsoft doesn't believe in its usage right now? In our small business, this is the reason we would never use it.
Microsoft always argument that HTML5 isn't fully finished. Then ASP.NET cannot be totally rewriten to follow it. Makes some sense, but...
You can do it by yourself: http://stephenwalther.com/blog/archive/2011/01/11/building-an-html5-app-with-asp-net.aspx.
But I realy believe that ASP.NET MVC is more flexible to it task.
Your question is pretty open-ended. What do you want out of HTML5? If you're just looking for controls, you run into a roadblock that ASP.Net web forms won't render the new HTML 5 input types with placeholders and custom keyboards like URL Input, Email input canvas, etc. I made an open-source project to make these plug and play with Web Forms.
If you're looking for other parts of the spec, pay special attention to whether or not the markup "fails gracefully". If you can optimize the experience with HTML5, but still keep a baseline quality for older browsers, I say go for it!

Can we use Razor syntax in ASP.NET Webforms (*.aspx pages)?

I'm liking the Razor syntax that Microsoft has developed for inline coding in their WebMatrix product (http://en.wikipedia.org/wiki/Microsoft_WebMatrix).
Now that Visual Studio SP1 has RTM'd, is it possible (and/or planned) to enable the use of Razor syntax in ASP.NET Webforms?
We (the ASP.NET team) currently have no plans to support the WebForms page model using Razor syntax. Furthermore it is unlikely that we would ever seriously consider this as the models are too different to make the two work together.
You can use Razor pages without MVC; this is called ASP.Net WebPages.
Just add .CSHTML files to a normal ASP.Net 4.0 project.
I explained how this works in my blog.
You could possibly integrate it using the RazorEngine available from Codeplex. It allows you to process razor outside of MVC. Though you don't get all the features you get from the MVC version of Razor, such as #Html and #Url and others.
I dare say that Microsoft have considered it, but there is no official word on the subject. Since you are not supposed to have C# or VB code in the ASPX file, you have to wonder about the point of adding Razor support to Web Forms. The code behind would still be a (partial) class file. You wouldn't put Razor there any more than you would put it in a class file in Web Pages or MVC. And swapping Server Controls and all that good declarative stuff for Html Helpers removes one of the key reasons for going the Web Forms route, IMO.
This really isn't that difficult to do. Working on it right now. Grab RazorEngine from CodePlex. It lets you compile Razor cshtml/vbhtml files into a class at runtime.
You can then take that class, and use it from a ASP.Net server control, inside its Render method. This is a great way to get HTML out of the body of a server control. Much, much cleaner.
Now, you can also add some methods that you can invoke from Razor. For instance, add something like RenderChild. Additionally, you could set the Server Control itself as the Model available to Razor. You could then invoke into the server control. Including doing something like grabbing one of it's child controls and invoking Render.

How is the HTML on this site so clean?

I work with C# at work but dislike how with webforms it spews out a lot of JavaScript not including the many lines for viewstate that it creates.
That's why I like coding with PHP as I have full control.
But I was just wondering how this sites HTML is so clean and elegant?
Does using MVC have something to do with it? I see that JQuery is used but surely you still use asp:required validators? If you do, where is all the hideous code that it normally produces?
And if they arent using required field validators, why not? Surely it's quicker to develop in than using JQuery?
One of the main reasons I code my personal sites in PHP was due to the more elegant HTML that it produces but if I can produce code like this site then I will go full time .net!
One of the goals of ASP.NET MVC is to give you control of your markup. However, there have always been choices with ASP.NET which would allow you to generate relatively clean HTML.
For instance, ASP.NET has always offered a choice with validator controls. Do you value development speed over markup? Use validators. Value markup over development speed? Pick another validation mechanism. Your comments on validators are kind of contradictory there - it's possible to use ASP.NET and still make choices for markup purity over development speed.
Also, with webforms, we've had the CSS Friendly Control Adapters for a few years which will modify the controls to render more semantic markup. ASP.NET 3.5 included the ListView, which makes it really easy to write repeater type controls which emit semantic HTML. We used ASP.NET webforms on the Microsoft PDC site and have kept the HTML pretty clean: http://microsoftpdc.com/Agenda/Speakers.aspx - the Viewstate could probably be disabled on most pages, although in reality it's only a few dozen bytes.
You were on the right track. It is the fact that they are using the ASP.NET MVC web framework. It allows you to have full control of your output html.
The ASP.NET MVC Framework is an alternative to the normal "web forms" way of doing ASP.NET development. With it you lose a lot of abstraction, but gain a lot of control.
Yes - MVC doesn't utilize the ASP.NET view state junk.