Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7079293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:39:16+00:00 2026-05-28T06:39:16+00:00

I am currently referencing this website for AD role management. The C# code is

  • 0

I am currently referencing this website for AD role management.

The C# code is working fine, but when I pasted the code inside my webpage along with the masterpage, the page gave me an error which says:

Content controls have to be top-level controls in a content page or a nested master page that references a master page.

May I know how should I set my masterpage in this case?

.ASPX page without masterpage:

<%@ Page Language="C#" %>

<%@ Import Namespace="System.Web.Security" %>
<%@ Import Namespace="System.Web.UI" %>

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

  string[] rolesArray;
  MembershipUserCollection users;
  string[] usersInRole;

  public void Page_Load()
  {
  ....
  }


  public void AddUsers_OnClick(object sender, EventArgs args)
  {
    ....
  }

  public void UsersInRoleGrid_RemoveFromRole(object sender, GridViewCommandEventArgs args)
  {
  ....
  }

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
  <title>Sample: Role Membership</title>
</head>
<body>
  <form runat="server" id="PageForm">
    <font face="helvetica" size="6" color="#455c75"><strong>Role Membership</strong></font><font face="helvetica" size="5" color="#455c75"><strong> Management</strong></font>
    <br /><asp:Label ID="Msg" ForeColor="maroon" runat="server" /><br />
    <table cellpadding="3" border="0">
      ...
    </table>
  </form>

Masterpage:

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

<!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 id="Head1" runat="server">
    <title>SOD</title>
    <link href="Styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
...
</body>
</html>

EDIT:

I tried inserting MasterPageFile="~/MainPage.master" into the first tag, which start my .aspx page with <%@ Page Language="C#" MasterPageFile="~/MainPage.master"%>, giving me the error mentioned above.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T06:39:17+00:00Added an answer on May 28, 2026 at 6:39 am

    The Masterpage contains HTML code and content areas. The pages that use the masterpage must, MUST, have all code in an <asp:Content> tag. You can’t have any sort of code outside of the Content tag.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently working on a project that contains many different Eclipse projects referencing each
I'm currently working on my Bachelors dissertation. This involves developing a software product and
I am currently working on a Swing Applet, and am having issues referencing my
Currently, I'm referencing images, stylesheets etc. like this on my home server: http://localhost/igniter/assets/images/ However,
Hey guys, I currently present my mp3s by referencing their file location into a
Currently I know of only two ways to cache data (I use PHP but
I'm writing a jQuery plug-in so I can reuse this code in many places
I'm currently debugging the next tier of my website in Firefox and found a
I am using ASP.NET and the Entity Framework to make a website. I currently
I have an ASP.net Web Site Project (.net 3.5). Currently all of the non-code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.