0

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?

2
  • 1
    Normally you'd put the <link rel... in the <head> section of your website. In this case, if possible add if to your Site.Master masterpage. Commented May 5, 2011 at 10:28
  • As a side note, unless there are specific reasons to use <b> tags, I'd use <strong> tags instead. Commented May 5, 2011 at 10:39

1 Answer 1

2

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>
Sign up to request clarification or add additional context in comments.

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.