1

I have a master page which has an exteral css page in the header. Includes the height of the pages, however only one page needs to be longer. So I figured inline css would be the best option over creating a whole other master page or creating a new css page that only has one line different. I looked through this site for an answer but ive only found how to change the external css link to one page, but like i said i dont want to add a whole new different page, I only need the hight property of the pages to be changed so is there a way to just override it by something similar to inline css? or is a new css page the only option?

4 Answers 4

2

If you are trying to add in the HTML page (seattle.html) then use the below code

<!--MS:
<style type="text/css">-->
#contentBox{ margin-left: 0; margin-right:0; width:100%; min-width:0; }  #contentRow{padding-top:0;}
<!--ME: </style>-->
Sign up to request clarification or add additional context in comments.

Comments

0

If you want a certain page to have just one difference, you don't need to copy and paste the whole stylesheet over to a different stylesheet. As long as it is included after (i think) the first stylesheet being included, all you need to put is the changes you want.

If you want to put a small bit of CSS on a HTML page without having a stylesheet, simply put it in

<style type="text/css">
css code here
</style>

I hope this works,

-Ben

7 Comments

So if I wrote that at the begining of the asp page, and put the div content height as the new height, it should work, while still using the other css from my external css page?
Yes, it should. I am not familiar with ASP that much but it should.
I put <style type="text/css"> ..... </style> at the begining of the content place holder, and it came back saying that it cannot be placed inside a div. That must be in reference of the master page. Should i place it elsewere?
Yea. Put it in the head tags if possible
If a style tag comes after a css file reference any styles it contains will override definitions in the .css file
|
0

First of all, you're talking about master pages, which are part of asp.net, not classic asp, so I'm retagging your question accordingly.

asp.net allows you to give the style tag the runat = server property. In header of am aspx page you could add

<style type="text/css" id="sitestyle" runat="server"></style>

In the codebehind you can then populate this as follows

sitestyle.InnerHtml = (your server generates css styles here);

Edit - master page with two content placeholders

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" %>

<html>
<head runat="server">
    <title></title>
    <asp:ContentPlaceHolder ID="ContentPlaceHolderHead" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">

        </asp:ContentPlaceHolder>
    </div>
    </form>
</body>
</html>

3 Comments

ah ok, I didn't know that about asp and asp.net. My master page starts with <%@ Page Title...... etc %> then a content place holder. If I add that tag either before or after the opening of the content place holder then it still comes with an error, that a style cannot be nested within a div, even though there are no divs. Not even in the master page.
actually, in the master page, the content place holder is inside a div. So i dont know how to get over this
Just add a header and add another content placeholder - see my edit above
0
     If You want to use the Inline css then you can use that inside the <style> tag.

But Inline and Internal css is not the good option. Because being as a good developer It is always a good practice that you use External css.

It will really help you to reuse your css.

&

Biggest Advantage is it will make your code more maintainable.
I hope this will help you.

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.