1

I have created a two usercontrols in asp.net and one webform . Now i want these two usercontrols to show in form in webform but it say that there must be one head with runat="server"

this is webform where i am using UserControl!

            <%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Light.master"  CodeBehind="AdministrationPage.aspx.cs" Inherits="DXApplication5.AdministrationPage" %>
        <%@ Register src="~/AdminPage/AssignmentTab.ascx" tagname="AssignmentUC" tagprefix="uc1" %>
          <asp:Content ID="MainContent" ContentPlaceHolderID="MainContent" runat="server">
        <table border="0">

<tr>
<td>
<div class="accountHeader">
     <uc1:AssignmentUC ID="CalendarUserControl1" runat="server" />  
</div>
</td>
</tr>
</table>

</asp:Content>

This is UserControl below:

<%@ Control Language="C#"  ClassName="AssignmentUC" AutoEventWireup="true" CodeBehind="AssignmentTab.ascx.cs" Inherits="DXApplication5.AdminPage.AssignmentTab" %>

4 Answers 4

1

I would add a single form to your masterpage, this may be the cause of your error.

I would also remove all other form server controls from your user controls and pages.

Try these steps:

  1. Go to Light.master master page file and make sure that this is in there somewhere <form id="form1" runat="server"> and a closing tag, the id may be different.
  2. Go to the following files AssignmentTab.ascx and AdministrationPage.aspx and remove any <form id="form1" runat="server"> and closing tags </form>
Sign up to request clarification or add additional context in comments.

5 Comments

You haven't posted the full code, I will try and add without it.
that's strange that i have only one form and it still not doing well :(
I have guests at home right now can i continue questioning here later? Please bear with me.
same that there is runat= servrer more than one. i have voted up your answer.
There has to be nested controls under calendar or another. Please post the markup for them.
0

Check user control code if it contains a head element. Also check all dependencies to see if there are head elements present in them.

1 Comment

i need to mention head - Now? :(
0

I think you have use <form id="formID" runat="server"> in both of your page and user Control .
Just remove runat="server" from your user Control Form tag .

1 Comment

No i just have added one form in master page -
0

Make sure you have in your user control cs file:

public partial class WebUserControl1 : System.Web.UI.UserControl

In ascx:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="WebUserControl1.ascx.cs" Inherits="WebUserControl1" %>

In aspx parent:

    <%@ Register  Src="WebUserControl1.ascx" TagPrefix="uc" TagName="WebUserControl1 " %>

 <uc:WebUserControl1  runat="server" ID="mycontrol" />

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.