Use Bootstrap 3 RC1 in the New MVC 5 - asp.net-mvc

Microsoft has used Bootstrap in their new ASP.Net MVC 5 template. It's really great. However it uses the version 2.3.1 of it and the Bootstrap guys are moving towards the 3 version already. I could just easily rewrite the entire views and the layouts based on the new version but I was wondering if somewhere, someone else has done it (maybe by a long shot the Microsoft folks?).

I know the rules (that I really appreciate) is to put code here instead of link for my blog post but it's just too many small corrections to put them here.
http://www.ghislainproulx.net/Blog/2013/09/using-bootstrap-3-with-visual-studio-2013-aspnet-mvc-template

I have created a NuGet package Bootstrap.MVC.EditorTemplates.Sample that contains a Bootstrap 3 based sample site, plus some additional bootstrap controls and culture-aware validation. This works with the VS 2013 RC MVC5 template.
It uses the Twitter.Bootstrap.Less package instead of the plain bootstrap package, it is best to "uninstall-package bootstrap" from the default MVC 5 site before installing it in the project.

The main idea of making Bootstrap 3 work on ASP.NET-MVC 5 project (or any other server side technology) is to put proper css and js files into the project and make Layout file use these.
This is very well covered in the blog by #Ghislain_Proulx.
Then all you have to do is follow the syntax rules of Bootstrap 3 in your Views.
One way to do it is use straight html markup. Another - use custom helpers. #Maarten has a cool open sourced EditorTemplates of these. However, I'd suggest using TwitterBootstrapMVC as it provides a high level of flexibility.
Disclaimer: I'm the author of TwitterBootstrapMVC and using it for Bootstrap 3 requires a license.

Now that Bootstrap 3 final release is out, and so is Visual Studio 2013 RC and ASP.NET MVC 5 RC, it's confirmed that the RTM of ASP.NET MVC 5 will come with Bootstrap 3 (even though it's not in ASP.NET MVC 5 RC yet).
Until ASP.NET MVC 5 RTM / Visual Studio 2013 RTM, the post referenced in the accepted answer would be the wya to go.

Related

Use MVC 4 style scaffolding in VS 2015 Update 3

I am updating a few year old website which was originally built with MVC4 (VS2012 perhaps). I am pretty sure after update 3 when I add a new view using scaffolding I now get the MVC5 style views using Bootstrap, etc. This site doesn't use bootstrap and there are no plans to add it at this time. Is there a way to reference the old style scaffolding template so I don't need to build (or rebuild) the view pages by hand after they created?
Currently using VS2015 Update 3
It appears that nuget package Microsoft.AspNet.Mvc is running 5.2.3. Is this the reason I am getting MVC 5 scaffolding templates?
Scaffolding uses Code Templates, but only to define the Create, List, Edit, Details,Delete and Empty Views. It means that the css are inherited from your _Layout.cshtml. Just remove the bootstrap reference from that and it should work. If you want to customize your Scaffolding layouts, just change the Code Template:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\ItemTemplates\CSharp\Web\MVC 4\CodeTemplates\AddView\CSHTML
More info:
http://www.hanselman.com/blog/ModifyingTheDefaultCodeGenerationscaffoldingTemplatesInASPNETMVC.aspx

challenges in upgrading Bootstrap Themed ASP MVC site, how to upgrade bootstrap + keep previous CSS / #Helper / Transpiler

I've built an ASP MVC site and used bootstrap, Jquery, knockout and signalR, and inherited a mix of 3rd party MVC code integrated with controls like syncfusion. (I don't have a choice in this matter, company decision)
After coding the HTML helpers in the views,
I manually applied all the bootstrap styles took sometime and got it
to work. Now, with upgrade/changes to bootstrap (RC 3.1) I am finding
myself back to square one, hunting through the code and replacing it manually, lots of
changes. Can you please share a better way to transpile/emit/bind the
bootstrap CSS classes into the helpers (i.e. in an independent way of the
technology helper, whether its ASP HTML MVC helper, Syncfusion HTML
MVC helper, Rad or FluentBootStrap)
Please provide a solution/recommendation to apply bootstrap CSS to ASP MVC pages
That's easy to separate and maintain and CSS upgrade's Programmtically
or globally configurable/settable/applicable
I've been thinking extension classes might be a good option, but not sure how I can achieve this, if you've can show me how to get the custom bootstrap CSS bound so I can programatically apply it or globally,
Is there a transpiler or Razor Declaritve Helper (I know about the nuget package, I tried applying it, and it turned out to be more of a template, than declarative extension binding, and I couldnt use it with other libraries Syncfusion or DevExpress)
or some other way, I would greatly appreciate it.
Here is an example of what I do currently, with the Syncfusion library
#Html.Syncfusion().Menu("myMenu").AutoFormat((Skins)ViewData["Themes"]) - performance hog
or better option 2 below
http://mvc.syncfusion.com/demos/ui/tools/Menu/Appearance
#(Html.Syncfusion().Button("btnNormal")
.Text("Save")
.Width(100)
.Height(50)
.ContentType(ContentTypes.TextAndImage)
.ImageUrl(Url.Content("~/Content/Images/Button/icon_save.png"))
.CustomCSS("CustomCss_Button") )
-> I changed/upgraded manually to BootStrap RC 3.1, I changed this last part to the bootstrap
.CustomCSS("btn-default dropdown-toggle btn-primary"))
Not sure this would be helpful to you, but check out TwitterBootstrapMVC. Right now it supports v2.* of TwitterBootstrap, but the support for v3.* is being built.
Our answer is from the experience we are going through. Here is what we found,
currently, The twitter bootstrap MVC is your best option IMHO, we are moving everything to it and its free! Its probably better the broiler plate option.
The 3.0 upgrade is a big question for us as well, so this is
something Dmitry can clarify.
Also, auto creating type safe bootstrap HTML views/sections for models is another question.
In addition you will face challenges with custom controls, we have a OLAP BI client, which looks / or doesn't not have the same consistent look. Dmitry can you answer how to resolve this with twitterbootmvc
Dmitry, will the twitterbootstrap upgrade, auto upgrade to the 3.0 bootstrap or do we have do anything manually?
I just discovered that in visual studio you can for the precompile of RAZOR into HTML.
Can you add that as an option to fluent

SinglePageApplication - match sample videos from 2012 Fall update

I am trying to recreate the ASP.NET Single Page application as demonstrated by Steven Sanderson
Single Page Applications - for desktop, mobile, tablet with ASP.NET MVC4
I have downloaded and installed the Build Preview - http://www.asp.net/vnext
I have using NuGet, tried to update my SPA Scaffolding to ASP.NET SPA MVC 4 (Beta)
I am running Visual Studio 2012
When i create a new MVC4 application, there are some distinctive differences between what i have and the demo's i see.
Primarily, after create a new project, if you view what you have the sites look completely difference
What Steve Sanderson Gets
What I Get
Then continuing to follow his example, he created a controller and has an option of
Single Page Application with read/write actions and views, using Entity Framework
This is not avaiable in my Create Controller Dialog
What Steve Sanderson Gets
What I Get
Why are my options differen't?
What have I not installed?
Thanks for any help
The new SPA template is a completely different template, as you have discovered. Short story ... the new template is revised to be a starting place, the old template was deemed too prescriptive.
The new template is a preview and will have more changes by the time it is released. The idea is you can use it as a starting point for a SPA and then add features and other libraries as needed.
UPDATE: If you want more info on what's in the latest template you can read my post here: http://www.johnpapa.net/insidespatemplate

User of Razor on an MVC 2 application

I am new to MVC so I am asking this question,
I have visual studio 2010 version 4.0.30319 SP1 Rel already installed and currently we are using MVC2 . I have been asked to you MVC3 razor view engine. So in order to get that I am assuming, I need to install this
http://www.microsoft.com/web/gallery/install.aspx?appsxml=&appid=MVC3
My question is, can I start developing using MVC3 in my existing project which is currently in MVC2 ? I dont want to modify the existing code or upgrade to MVC3. Is it possible ?
Is there any other thing that I need to download and install. What are the changes that I need to make in my web.config file or any other file to make this MVC2 project run ?
Please help
This isnt something iv'e done before but the link below will make the appropriate referential changes in order to create razor view pages.
MVC 3 Conversion
However there was a link I found on that page in the comments provided by mpost dated july 15h 2011 to a exe conversion tool. Would be interested to see how much success, if any you get from it.
Razor view converter

How to update MVC 1 application to MVC 3 with razor in ASP.NET MVC

I have a MVC 1 application who i want to migrate to MVC 3 last days. i make a fresh project and rewrite all logic and put in new.
at a half :- i hear that do not changes in admin. so i include the logic from old code to fresh.
now code is not worked. so all my work look like gone.
Now i thing to migrate the project not by making fresh perhaps by using old solution [proj] i have to make upgraded to MVC 3.
so i can include changes i make in new to old.
so i need a thing that:-
How i can make MVC 1 project to MVC 3 project who can work with razor. second thing i need that used old sollution not making new sollution for migration.
are you know any thing to upgrade i can MVC 1 project to MVC 3 project. How ?
Thanks for help
Martin Aatmaa has a post on how to upgrade manually from MVC 1 to MVC 2 or you could try Eilon Lipton's upgrading tool
Then from there you might be able to use MVC 3 upgrader tool also by Eilon Lipton
I'm not aware of any tools to upgrade from MVC 1 to MVC 3 directly.
Once upgraded to MVC 3 you will then have to go through each view manually and change the code from an ASPX view to a Razor view. Note that both view engines can be used along side each other in the same project.

Resources