Mahadev
Mahadev

Reputation: 856

Form tag on master page and Content pages

I have a ASP.NET application with one Master Page and Multiple content pages.

This is a start of Master Page

<body>
<form runat="server">
    <asp:ScriptManager runat="server">
        <Scripts>
            <%-- Scripts Omitted --%>
        </Scripts>
    </asp:ScriptManager>
            .
            .
            .
            .
            .

Now, i have a Registration page with a form to submit. Here is the start

<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
<br />
<form id="Form1" runat="server">
<div class="register">
    <br />
            .
            .
            .

Whenever I tried to run the Register.aspx page, it gives me error as : A page can have only one server-side Form tag. and I know its because I have a Form tag on Master Page. Now if I tried to remove the form tag from Master Page (Which I thought unnecessary), I got error as : Control 'ctl01' of type 'ScriptManager' must be placed inside a form tag with runat=server.

My Question is : How can I use Form tag on Master as well as on content page without removing ScriptManager. Or is there any alternative to accomplish this ?

Upvotes: 1

Views: 3388

Answers (1)

Richard
Richard

Reputation: 30628

Just remove the form tag from your content pages - the form tag on the master page will be sufficient. You will need the ContentPlaceHolder tags on the master page to be within the form for this to work.

Upvotes: 1

Related Questions