Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Master page - cannot add controls

Reply
Thread Tools

Master page - cannot add controls

 
 
=?Utf-8?B?QW50?=
Guest
Posts: n/a
 
      10-20-2007
Hi,
I'm a newbie to master pages & have added images dragged from my image
folder directly to a master page. This image is available to all forms that
use this master page.
However, if I add an image control, a frame or layer object to my master
page, then save & build, these don't show up on my forms, nor does anything
in them.

Is this expected behaviour or am I misundertanding the way a master page
should be used?

many thanks for any help here

Ant
 
Reply With Quote
 
 
 
 
Kevin Spencer
Guest
Posts: n/a
 
      10-20-2007
A MasterPage is used in an ASP.Net Page to provide content that is common to
any Page that employs (or hosts) it. It is employed via the @Page tag in the
hosting Page, as in the following example:

<%@ Page Language="C#" Inherits="Default" CodeFile="Default.aspx.cs"
masterpagefile="MainPage.master"
title="Example" AutoEventWireup="true"%>

Once the MasterPage is hosted in a Page, the contents of the Page will be
the contents of the MasterPage when it is requested via HTTP by a browser.

The MasterPage may also have ContentPlaceHolder Controls in it, which allow
any Page hosting it to add additional Controls and HTML content inside the
bounds of the Control. In the MasterPage, a ContentPlaceHolder looks like
this:

<asp:ContentPlaceHolder id="MainContentPlaceHolder" runat="server">
</asp:ContentPlaceHolder>

In the hosting Page, the reference to the ContentPlaceHolder looks like
this:

<asp:Content id="Content1" runat="server"
contentplaceholderid="MainContentPlaceHolder">
<!-- Here is where the additional Page-specific content belongs -->
</asp:Content>

Now, from your description, I can't tell what you're doing. For example, you
say that "the image is available to all forms that use this master page."
What do you mean by "available?" And what do you mean by "these don't show
up on my forms, nor does anything in them?" Where do they not show up? In
your development environment? In the code for the pages? In a browser?

--
HTH,

Kevin Spencer
Chicken Salad Surgeon
Microsoft MVP

"Ant" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
> I'm a newbie to master pages & have added images dragged from my image
> folder directly to a master page. This image is available to all forms
> that
> use this master page.
> However, if I add an image control, a frame or layer object to my master
> page, then save & build, these don't show up on my forms, nor does
> anything
> in them.
>
> Is this expected behaviour or am I misundertanding the way a master page
> should be used?
>
> many thanks for any help here
>
> Ant



 
Reply With Quote
 
 
 
 
Mark Rae [MVP]
Guest
Posts: n/a
 
      10-20-2007
"Kevin Spencer" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

> Now, from your description, I can't tell what you're doing.


The OP is placing controls *inside* the <asp:ContentPlaceHolder /> tag on
the MasterPage instead of the <asp:Content /> tag on the content page...


--
Mark Rae
ASP.NET MVP
http://www.markrae.net

 
Reply With Quote
 
=?Utf-8?B?QW50?=
Guest
Posts: n/a
 
      10-22-2007
Hi Mark,

I don't know what happened but it's all fine now. I just started from
scratch & now no issues. Before, whenever I changed content on the master
Page after associating it with web pages, the changes wouldn't show up on the
web page unless I chose "Default to Master Content" but then I would lose all
the local content I added, unless I chose "Choose Custom content", so it was
either one or the other (?). Additionally, it was rendering button controls
right across the screen.
There must have been something wrong with that initial Master page 'build'.
As you noted, it was not adding controls into content placeholder in the
markup when it should have.

Anyway, alls well that end well...

P.S It's a great tool. I'm sold!



"Mark Rae [MVP]" wrote:

> "Kevin Spencer" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>
> > Now, from your description, I can't tell what you're doing.

>
> The OP is placing controls *inside* the <asp:ContentPlaceHolder /> tag on
> the MasterPage instead of the <asp:Content /> tag on the content page...
>
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net
>
>

 
Reply With Quote
 
Mark Rae [MVP]
Guest
Posts: n/a
 
      10-22-2007
"Ant" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

> As you noted, it was not adding controls into content placeholder in the
> markup when it should have.


In fact, it's the other way round... You had placed controls *inside* your
<asp:ContentPlaceHolder> tag when you shouldn't, because they will get
overwritten when the page builds itself...


--
Mark Rae
ASP.NET MVP
http://www.markrae.net

 
Reply With Quote
 
=?Utf-8?B?QW50?=
Guest
Posts: n/a
 
      10-22-2007
Hi Mark,

Thanks for the reply; the odd thing is though that I hadn't touched the
Markup at all. It had all been done from the UI, so I don't know how it could
have happened.
but anyway...

Thanks

Ant

"Mark Rae [MVP]" wrote:

> "Ant" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>
> > As you noted, it was not adding controls into content placeholder in the
> > markup when it should have.

>
> In fact, it's the other way round... You had placed controls *inside* your
> <asp:ContentPlaceHolder> tag when you shouldn't, because they will get
> overwritten when the page builds itself...
>
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Access Master Page Controls from page.aspx doesn't inherit from master SerpentKiss2010 ASP .Net 0 04-06-2011 02:46 PM
Setting the value of a Master page's control's property using a property of the Master page Nathan Sokalski ASP .Net 25 03-04-2010 03:42 AM
this.Controls.Add(Control) Does Not Add Control to child collection (this.Controls.Count == 0) Chad Scharf ASP .Net 3 10-18-2007 03:53 PM
Can a master page be built from another master page Zeba ASP .Net 1 02-22-2007 10:55 AM
seeking servlet "Master" keep getting "Master/servlet/Master" not found. Tomcat 5.0.25 Doug McCann Java 1 08-05-2004 09:16 PM



Advertisments