3

I need to use a css template for webpage I am building but I don't know how to use in asp.net mvc4. so How to use CSS Templates with ASP.NET MVC 4 in visual studio 2012 for web application?

3 Answers 3

9

It's simple:

  1. Move your css and images into ~/Contents folder.

  2. Move your js files into ~/Scripts folder

  3. Copy and paste your html snippets to cshtml files

    On 3rd step you need to port the layout portion of your template to ~/Veiws/Shared/_Layout.cshtml. Here you need to point references to your css and js correctly. For example:

    And also you need to be aware that _Layout.cshtml should contain @RenderBody(). That's where all child views will be inserted.

Just found a video with basic demonstration of process: link

Sign up to request clarification or add additional context in comments.

Comments

0

It is the same as you use for simpe HTML files. In the solution you can add an existing item and your browse your CSS file which will be added in the Content folder then you have to reference it in the page where it will be used. If you want to apply all the rules to every page you can reference it in the _Layout.cshtml page which is called before everypage. It is like the container.

You have many options to call it. I will suggest you also reading Bundling and minification in this link which is also interesting to know.

Comments

0

There are Few Steps:

  1. Make Directory inside Content folder in my case mytemplate.
  2. Copy all your template content inside mytemplate folder.
  3. Add new Layout page in View>Shared Folder in my case _mytemplate.cshtml.
  4. open your template Index.html file inside any editor(i.e: Dreamviewer,Notepad etc).
  5. Copy all header stuff from your html file to inside of Header in _mytemplate.cshtml file.
  6. Copy all body stuff Inside of your Index.cshtml to Layout page.
  7. Save your Project by Cntrl+S and Run it in browser. Thats it.

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.