css and master page problem

L

laziers

Hi,
I have a "little" problem. I'v got a very simple page:

<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/
TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<style type="text/css">
#form1{background-color: blue}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
text
</div>
</form>
</body>
</html>

I run it, and everything is ok [the text in form is blue], BUT! when I
create a masterpage:

<%@ Master Language="C#" AutoEventWireup="true"
CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<style type="text/css">
#form1{background-color: blue}
</style>
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<div>
text
<asp:ContentPlaceHolder id="ContentPlaceHolder1"
runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>

the text isn't blue now. What should I do to have a blue text?
 
M

Mark Rae [MVP]

What should I do to have a blue text?

Avoid using object names in your style... If you do a View Source on your
page, you'll see that you don't have a "form1" any more...
 
L

laziers

Avoid using object names in your style... If you do a View Source on your
page, you'll see that you don't have a "form1" any more...

I see, but look at this:

form1 is in the: default.aspx page, ale form2 is in the: default2.aspx
I want blue text in form1 and red in form2,

the style: form {background-color: blue} will not work good.

?
 
N

Naraendirakumar R.R.

Hi.
We had to acommodate a similar design. We ended up introducing <div> as the
only child of the form tag, to solve this problem. We applied the style to
the <div> tag.

Cheers,
-Naraen
 
L

laziers

Hi.
We had to acommodate a similar design. We ended up introducing <div> as the
only child of the form tag, to solve this problem. We applied the style to
the <div> tag.

yes, with dives works fine, thanks

cheers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top