1,105,177 Community Members

Can't I add asp linkbutton tag to master page in asp.net/c#

Member Avatar
duranvskp
Newbie Poster
2 posts since Mar 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi

I'm trying to build a master page. What I'm trying to do is have a header in the master page with login and register link buttons (which would change to username and sign out) and there are content pages like home.aspx, shoppingcart.aspx, checkout.aspx which would inherit the master page with that header. So in that process i wrote the following code in master page (First.Master). And i tried to inherit the master page in home.aspx through this following code Inherits="SampleMasterProject.First" in the page tag

<body>
        <form id="form1" runat="server">
        <div>
            <asp:ContentPlaceHolder ID="Header" runat="server">        
                <asp:LinkButton ID="UserNameLinkBtn" Text="UserName" runat="server"></asp:LinkButton>
                <asp:LinkButton ID="PwdLinkBtn" Text="Password" runat="server"></asp:LinkButton>
            </asp:ContentPlaceHolder>
        </div>
        </form>
    </body>

But I get following error


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

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: Content controls have to be top-level controls in a content page or a nested master page that references a master page.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[HttpException (0x80004005): Content controls have to be top-level controls in a content page or a nested master page that references a master page.]
System.Web.UI.MasterPage.CreateMaster(TemplateControl owner, HttpContext context, VirtualPath masterPageFile, IDictionary contentTemplateCollection) +8836686
System.Web.UI.Page.get_Master() +54
System.Web.UI.Page.ApplyMasterPage() +15
System.Web.UI.Page.PerformPreInit() +45
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +328


Please help me.

Thank you in anticipation

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: