Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / September 2007

Tip: Looking for answers? Try searching our database.

Newbie question:  Content and Master

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Shelly - 31 Aug 2007 00:17 GMT
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.

Signature

Shelly

John Mott - 31 Aug 2007 00:52 GMT
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

>I am just learning ASP and .NET (coming from a php, C, Java background) so
>please bear with me.
[quoted text clipped - 7 lines]
>
> .... or please tell me how to do those things.
clintonG - 31 Aug 2007 01:11 GMT
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/

> 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
[quoted text clipped - 25 lines]
>>
>> .... or please tell me how to do those things.
clintonG - 31 Aug 2007 01:14 GMT
// google
htmlhead class site:msdn2.microsoft.com

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

>I am just learning ASP and .NET (coming from a php, C, Java background) so
>please bear with me.
[quoted text clipped - 7 lines]
>
> .... or please tell me how to do those things.
Shelly - 31 Aug 2007 02:32 GMT
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

> // google
> htmlhead class site:msdn2.microsoft.com
[quoted text clipped - 14 lines]
>>
>> .... or please tell me how to do those things.
William Main - 31 Aug 2007 05:00 GMT
the style should be coded as

   style="height:35;"

>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
[quoted text clipped - 41 lines]
>>>
>>> .... or please tell me how to do those things.
clintonG - 01 Sep 2007 15:14 GMT
<snip />
> 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
Shelly - 02 Sep 2007 03:13 GMT
> <snip />
>> Is there somewhere that you can point me to find out what all the
[quoted text clipped - 6 lines]
>
> <%= 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
Alan Silver - 02 Sep 2007 23:10 GMT
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 <object> tag should do what you want instead.

>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
will explain the full details of the CSS needed to style a <td> (amongst
many other things).

>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...

<img src="image.gif" alt="">

> 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

Signature

Alan Silver
(anything added below this line is nothing to do with me)


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.