Hari Gillala
Hari Gillala

Reputation: 11926

MVC, HTML with ASP.NET Linking

I want to use custom buttons in my MVC Page. I am designing the View Page.

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>

MainMenu

<!-- Main Menu Div-->
<form id="MainMenu" runat="server">
 <div id="MainMenuFirstView">
<h2 class="LabelHeader">

<b>
     &nbsp &nbsp &nbsp &nbsp <u>View </u>
 </b>

</h2>
<h3>
<asp:Button ID="btnHome" runat ="server" Text ="Home" Width="15%" CssClass="Button" SkinID= "Button" />
<asp:Button ID="btnNewUser" runat ="server" Text ="Add New User" Width="15%" CssClass="Button"/>
<asp:Button ID="btnAmendUser" runat ="server" Text ="Amend User" Width="15%"  CssClass="Button"  />
<asp:Button ID="btnAddNewAbsence" runat ="server" Text ="Add New Absence" Width="15%"  CssClass="Button" />
<asp:Button ID="btnAmendAbsence" runat ="server" Text ="Amend Absence" Width="15%"  CssClass="Button"  />
<asp:Button ID="btnAddJobRole" runat ="server" Text ="Add Job Role" Width="15%"  CssClass="Button" />
<asp:Button ID="btnAmendJobRole" runat ="server" Text ="Amend Job Role" Width="15%"  CssClass="Button" />
<asp:Button ID="btnAddShiftEvent" runat ="server" Text ="Add Shift Event" Width="15%"  CssClass="Button" />
<asp:Button ID="btnAmendShiftEvent" runat ="server" Text ="Amend Shift Event" Width="15%"  CssClass="Button" />
<asp:Button ID="btnAddDMICase" runat ="server" Text ="Add DMI Case" Width="15%" CssClass="Button"  />
<asp:Button ID="btnAmmendDMICase" runat ="server" Text ="Amend DMI Case" Width="15%"  CssClass="Button" />    
</h3>
</div>
</form>
</asp:Content>

If I want to use this a CSS file, How do I link it in this page?

Like: <link rel="stylesheet" type="text/css" href="style.css" />

In which part of the page I have to use this?

Upvotes: 0

Views: 109

Answers (1)

David Glenn
David Glenn

Reputation: 24532

You can add the stylesheet reference directly to your master page and it will be applied to all pages like

<head>
  <!-- ...other stuff here  -->
  <link rel="stylesheet" type="text/css" href="style.css" />
</head>

Or if you want to be able to add different stylesheets to different pages then you can add a content placeholder to your master page

<head>
  <!-- ...other stuff here  -->
  <asp:ContentPlaceHolder ID="Styles" runat="server"></asp:ContentPlaceHolder>
</head>

Then on your view page use

<asp:Content ContentPlaceHolderID="Styles" runat="server">
  <link rel="stylesheet" type="text/css" href="style.css" />
</asp:Content>

Also note that in MVC you do not use controls or other WebForms server controls. You should use HtmlHelpers or HTML directly.

<button id="btnHome" class="button">Home</button>

Upvotes: 2

Related Questions