Newbie question: Content and Master

S

Shelly

I am just learning ASP and .NET (coming from a php, C, Java background) so
please bear with me.

Where can I find a simple example of a master page which references a css
style sheet, and a content file that uses that master file. I would like to
see how to include the style sheet and whether the content file needs the
<form> since the master file already has it encompassing the holder for the
content file. Also, I assume the content file would not require <head> or
<body> for the same reason.

..... or please tell me how to do those things.
 
J

John Mott

If you're using Visual Studio the connection between the master page and the
content page is set up automatically. When you 'add new item' one of the
options is to create a page which is associated with a master page, and you
select the master page as part of the new item wizard. The specific plumbing
is the "MasterPageFile" in the content page, that is how it knows which
master page it goes with.

You are correct that there is only one <form> tag, in the master page. thats
also where the <html> goes.

You put the css reference in the master file in the <head> tag, just as you
would normally. The page is rendered in such a way that the content page is
placed within the master page, so it has the same access to the styles as if
it were directly inline. So, you just refer to the styles in the content
page as you normally would.

john
 
C

clintonG

Actually, it is incorrect to say the content page is placed within the
master page when the page is compiled. It is exactly the opposite which
confuses everybody that has not done the required reading to understand how
MasterPages actually work. But its good to take a stab at explaining it as
we would amble about ignorant never learning or understanding our mistakes.

A thorough understanding of the page compilation model clears it up as well
as reading K. Scott Allen's collection of definitive studies...
http://odetocode.com/

<%= Clinton Gallagher
NET csgallagher AT metromilwaukee.com
URL http://clintongallagher.metromilwaukee.com/


John Mott said:
If you're using Visual Studio the connection between the master page and
the content page is set up automatically. When you 'add new item' one of
the options is to create a page which is associated with a master page,
and you select the master page as part of the new item wizard. The
specific plumbing is the "MasterPageFile" in the content page, that is how
it knows which master page it goes with.

You are correct that there is only one <form> tag, in the master page.
thats also where the <html> goes.

You put the css reference in the master file in the <head> tag, just as
you would normally. The page is rendered in such a way that the content
page is placed within the master page, so it has the same access to the
styles as if it were directly inline. So, you just refer to the styles in
the content page as you normally would.

john
 
S

Shelly

I got it to pull in the master page. I included a lot of stuff from another
site that I wrote in php and the stuff before and after what is in the
Content file is in html. (As a learning experience I am trying to redo this
site using ,net and aspx). I ran into several problems:

1 - How do I specify the style sheet? The CssClass value is not defined is
the message I get.
2 - It doesn't recognize <embed>. I have a Flash stuff at the top.
3 - In <td> it says that "height" is obsolete and that I should use a newer
one. What is the newer one? I tried style="height=35". However, doesn't
whatever is in the "style" have to be in double quotes, so how would one
enclose the "35"?
4 - It says that "background" is invalid in <td>. Since I point to an image
file, which appears in the browser by the way, what is the proper one to
use? Obviously, it must be getting it because when I test it, the image
appears.
5 - It say that "img" requires the "alt" tag. I currently don't have one.
What should I use?
6 - It also says that bgcolor is outdated. Again, what is the replacement?
Is there somewhere that you can point me to find out what all the
replacements are and their syntax?
7 - Ditto for "align" in <div>

Thanks.

Shelly



clintonG said:
// google
htmlhead class site:msdn2.microsoft.com

<%= Clinton Gallagher
NET csgallagher AT metromilwaukee.com
URL http://clintongallagher.metromilwaukee.com/
 
W

William Main

the style should be coded as

style="height:35;"


Shelly said:
I got it to pull in the master page. I included a lot of stuff from
another site that I wrote in php and the stuff before and after what is in
the Content file is in html. (As a learning experience I am trying to redo
this site using ,net and aspx). I ran into several problems:

1 - How do I specify the style sheet? The CssClass value is not defined
is the message I get.
2 - It doesn't recognize <embed>. I have a Flash stuff at the top.
3 - In <td> it says that "height" is obsolete and that I should use a
newer one. What is the newer one? I tried style="height=35". However,
doesn't whatever is in the "style" have to be in double quotes, so how
would one enclose the "35"?
4 - It says that "background" is invalid in <td>. Since I point to an
image file, which appears in the browser by the way, what is the proper
one to use? Obviously, it must be getting it because when I test it, the
image appears.
5 - It say that "img" requires the "alt" tag. I currently don't have one.
What should I use?
6 - It also says that bgcolor is outdated. Again, what is the
replacement? Is there somewhere that you can point me to find out what all
the replacements are and their syntax?
7 - Ditto for "align" in <div>

Thanks.

Shelly
 
C

clintonG

Is there somewhere that you can point me to find out what all the
replacements are and their syntax?
<snip />

Damn. They call it the web and all your questions can be discovered using
your preferred search engine to search the web. It sounds like you need A
LOT of help with basic HTML. Your questions are no longer about aspnet.

<%= Clinton
 
S

Shelly

clintonG said:
<snip />

Damn. They call it the web and all your questions can be discovered using
your preferred search engine to search the web. It sounds like you need A
LOT of help with basic HTML. Your questions are no longer about aspnet.

<%= Clinton

1 - I know **basic** html. My daughter would do all the pretty stuff
(html), and I would do all the programming and talking to the database and
database design (php, mysql).
2 - The question was about what to put into "alt". I searched the web
FIRST, but the question I had was rather specific. So, after not finding
it, I asked the experts who would probably know it off the top of their
heads. One did - leave it blank as "".
3 - I have progressed to where I am putting just about everything into css.
Some of the translations are not straightforward (such as cellpadding and
cellspacing), but on the whole it has been simple. I simply defined some
new class values in the style sheet.

My next questions will be more specifically on ASP.NET, but I had to get to
this point.

Thanks everyone for their help so far.

Shelly
 
A

Alan Silver

As mentioned before, a lot of these are basic HTML and CSS questions, so
you would probably do well to get a book on standards-based web design,
as that would help immensely.
1 - How do I specify the style sheet? The CssClass value is not
defined is the message I get.

A few ways...

1) Add a <link> tag in the <head> section of your HTML. This will
probably be in the master page, but does not have to be.

2) Use themes. That way you don't need to include the CSS file yourself,
as the ASP.NET engine will do it for you.

3) There are ways of using properties of the page to set style sheets,
but I don't see the point as they are more complex, and have no benefit
IMO.
2 - It doesn't recognize <embed>. I have a Flash stuff at the top.

<embed> has never been valid HTML. It was introduced by either MS or
Netscape during the browsers wars, but was never adopted officially.

The said:
3 - In <td> it says that "height" is obsolete and that I should use a
newer one. What is the newer one? I tried style="height=35".

Height, along with (almost) all other presentation-based attributes is
obsolete as this sort of stuff should be done with CSS.

The reason your CSS isn't working is that your syntax is wrong. It
should be... style="height:35px" - note that you need units there. Just
using style="height:35" is invalid, and can give unpredictable results.
However, doesn't whatever is in the "style" have to be in double
quotes, so how would one enclose the "35"?

See previous.
4 - It says that "background" is invalid in <td>. Since I point to an
image file, which appears in the browser by the way, what is the proper
one to use? Obviously, it must be getting it because when I test it,
the image appears.

Again, the background attribute is obsolete. The following will set a
background for a <td>...

<td style="background: #fff url(image.gif)">

This will set the background of the cell to white, and use image.gif for
a background image. Again, a good book on standards-based web design
5 - It say that "img" requires the "alt" tag. I currently don't have
one. What should I use?

Depends what the image is there for. The alt attribute (it's not a tag,
it's an attribute of the <img> tag) is intended to supply alternate text
in case the image is not rendered. Therefore, the alt text should
describe the image.

If your image does not have any semantic meaning (which begs the
question why you are using it), then just set the alt text to an empty
string...

6 - It also says that bgcolor is outdated. Again, what is the
replacement?

See above for the background element in CSS.
Is there somewhere that you can point me to find out what all the
replacements are and their syntax?

www.w3schools.com is the definitive source for info on CSS and HTML.
There are many good sites and books around that will explain them in
easier terms for a beginner.
7 - Ditto for "align" in <div>

<div style="align:right">...</div>

However, aligning in divs isn't as easy as it sounds as you have to
understand how divs work. Again, a good book on CSS will help.

FWIW I found Eric Meyer's two "...On CSS" books very good for learning
basic CSS. They show you how to convert a pre-CSS layout to a CSS one,
and are presented in a very clear way.

HTH
 

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,770
Messages
2,569,583
Members
45,072
Latest member
trafficcone

Latest Threads

Top