Master page - cannot add controls

Discussion in 'ASP .Net' started by =?Utf-8?B?QW50?=, Oct 20, 2007.

  1. 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
     
    =?Utf-8?B?QW50?=, Oct 20, 2007
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:...
    > 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
     
    Kevin Spencer, Oct 20, 2007
    #2
    1. Advertising

  3. "Kevin Spencer" <> wrote in message
    news:...

    > 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
     
    Mark Rae [MVP], Oct 20, 2007
    #3
  4. 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" <> wrote in message
    > news:...
    >
    > > 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
    >
    >
     
    =?Utf-8?B?QW50?=, Oct 22, 2007
    #4
  5. "Ant" <> wrote in message
    news:...

    > 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
     
    Mark Rae [MVP], Oct 22, 2007
    #5
  6. 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" <> wrote in message
    > news:...
    >
    > > 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
    >
    >
     
    =?Utf-8?B?QW50?=, Oct 22, 2007
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Doug McCann
    Replies:
    1
    Views:
    1,099
    William Brogden
    Aug 5, 2004
  2. Zeba
    Replies:
    1
    Views:
    528
    Mark Rae
    Feb 22, 2007
  3. Chad Scharf
    Replies:
    3
    Views:
    932
    Chad Scharf
    Oct 18, 2007
  4. Nathan Sokalski
    Replies:
    25
    Views:
    1,476
    Nathan Sokalski
    Mar 4, 2010
  5. SerpentKiss2010
    Replies:
    0
    Views:
    2,528
    SerpentKiss2010
    Apr 6, 2011
Loading...

Share This Page