Sign In | Register Now About Bytes | Help | Site Map
Connecting Tech Pros Worldwide

using Css and master page

Question posted by: raghulvarma (Member) on July 4th, 2008 02:46 AM
I have created a master page
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
Expand|Select|Wrap|Line Numbers
  1.  
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3.  
  4. <html xmlns="http://www.w3.org/1999/xhtml" >
  5. <head runat="server">
  6. <title>Untitled Page</title>
  7. </head>
  8. <body>
  9. <form id="form1" runat="server">
  10. <div>
  11. <h1 style="color:blue">This is From Master page</h1>
  12. <table width="80%">
  13. <tr valign="top">
  14. <td style="width:200px">
  15. to:do
  16. </td>
  17. <td>
  18. <asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
  19. </asp:contentplaceholder>
  20. </td>
  21. </tr>
  22. </table>
  23.  
  24. </div>
  25. </form>
  26. </body>
  27. </html>


then i used that master page in my .aspx pages as
Expand|Select|Wrap|Line Numbers
  1.  
  2. <%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/MasterPage.master" CodeFile="Default.aspx.cs" Inherits="_Default" %>
  3.  
  4.  
  5. <asp:Content ID="content1" runat="server" ContentPlaceHolderID="ContentPlaceHolder1">
  6.  
  7. <asp:Label runat="server" ID="lbl1" Text="User Name" style="position:absolute; left: 265px; top: 130px;"></asp:Label>
  8. <asp:TextBox runat="server" ID="txt1" style="position:absolute; left: 385px; top: 130px;"></asp:TextBox>
  9. <br />
  10. <asp:Label runat="server" ID="Lbl2" Text="password" style="position:absolute; left: 265px; top: 160px;"></asp:Label>
  11. <asp:TextBox runat="server" ID="txt2" style="position:absolute; left: 385px; top: 160px;"></asp:TextBox>
  12. </asp:Content>

all these work fine but if I need to add a style sheet to my aspx page I am not able to do so because I am not able to get the tag of <link> which is used to link a css to our page how has it to be done?
any clues????

raghul
deepant's Avatar
deepant
Newbie
5 Posts
July 5th, 2008
09:38 AM
#2

Re: using Css and master page
Hi,

you must link your css file in teh master page itself, so that when you inherit the master page when you creating a page the stylesheet applied with the master page will be applied to your created pages also

you can attach the css file in the master pages using the <link> tag

you can use this tag in the <head> section

<link href="your stylesheet name with location" rel="stylesheet" type="text/css" />

you should move all your styles to a seperate stylesheet file(.css) so that it is easy to change if ther is any changes in the style

if you change the style in the stylesheet it will be applied to all your pages

Thanks,
Hema

Reply
Reply
Not the answer you were looking for? Post your question . . .
189,088 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Latest Articles: Read & Comment
Top .NET Forum Contributors