Click here to Skip to main content
12,075,066 members (62,938 online)
Rate this:
Please Sign up or sign in to vote.
See more: ASP.NET

i have a usercontrol page as below

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<div id="header" class="header">
   <h1 class="h1">TrackU: Student and Vehicle Tracking System</h1>
    <form runat="server" id="fomr2">
    <p class="p"><asp:LinkButton runat="server" ID="logBtn" ForeColor="White" Text="Logout"></asp:LinkButton></p>
   <ul class="ul">
       <li class="li"><a class="lia" href="/Admin/Fleet.aspx">Fleet</a></li>
       <li class="li"><a class="lia" href="/Admin/StudentInfo.aspx">Student Info</a></li>
       <li class="li"><a class="lia" href="/Admin/RouteSettings.aspx">Route Settings</a></li>
       <li class="li"><a class="lia" href="/Admin/Reports.aspx">Reports</a></li>

and the aspx page with usercontrol as below,

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Fleet.aspx.cs" Inherits="M2iSTS2.Admin.Fleet11" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<%@ Register src="~/UserControl/Header.ascx" TagName="Header" TagPrefix="UserControl" %>
<%@ Register src="~/UserControl/Footer.ascx" TagName="Footer" TagPrefix="UserControl" %>

<html xmlns="">
<head runat="server">
    <link rel="Stylesheet" href="" />  
    <UserControl:Header ID="Header"  runat="server"/> 
    <form id="form1" runat="server">
     <asp:ScriptManager ID="ScriptManager1" runat="server">
<table border="1">
       <td style="width:250px;height:100%;background-color: #CEF">         
          <asp:UpdatePanel runat="server" ID="updatePanel1">
          <table align="center">
                      <asp:ImageButton ID="vehiclelistBtn" runat="server" 
                          ImageUrl="~/image/vehiclelist_btn.png" onclick="vehiclelistBtn_Click" />
                      <asp:ImageButton ID="driverlistBtn" runat="server" 
                          ImageUrl="~/image/driver_list.png" onclick="driverlistBtn_Click" />
       <td style="width:100%;height:100%">       
       <div  id ="map_canvas" style="height:635px">
    <UserControl:Footer ID="Footer1"  runat="server" />

But it giving error as

A page can have only one server-side Form tag.

How to avoid this?

Posted 17-Dec-12 19:56pm
faisal23 18-Dec-12 1:08am
Try this may be it works ....
tag use before header user control ...
<form id="form1" runat="server">
<UserControl:Header ID="Header" runat="server"/>
hasbina 18-Dec-12 1:21am
getting the same error..
Krunal Rohit 18-Dec-12 1:11am
remove any one form tag from code...
hasbina 18-Dec-12 1:19am
@krunal Rohit
sir, when i remove the form tag from linkbutton in usercontrol it giving error as,
"LinkButton must be placed inside a form tag with runat=“server”.

when i remove the form tag from aspx page, it giving error as,

Control 'ScriptManager1' of type 'ScriptManager' must be placed inside a form tag with runat=server.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

An Usercontrol never have the Form tag. when you use UserControl in your page it will automatically get the form tag through your page.

Note: There must be only only one form tag in a page.

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

you must:

1. remove the form tag from the ascx page (user control)
2. Place the user control between the form tags on the main aspx page like this:

<form id="form1" runat="server">
 <usercontrol:header id="Header" runat="server" xmlns:usercontrol="#unknown"> </usercontrol:header></form>


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.160208.1 | Last Updated 18 Dec 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100