Usercontrol within another usercontrol - ajax unknown server tag

Last post 05-08-2008 5:18 PM by blumonde. 14 replies.

Sort Posts:

  • Usercontrol within another usercontrol - ajax unknown server tag

    05-09-2007, 2:46 PM
    • Loading...
    • purell
    • Joined on 06-30-2006, 2:17 AM
    • Posts 199

    I have an updatepanel on 1.ascx - i drag that over to 2.ascx (that doesn't have any updatepanels).  Then I drag 2.ascx to main.aspx.  main.aspx doesn't recognize the updatepanel from 1.ascx.  If I drag 1.ascx to main.aspx it works.  But I need to have two layers.

    Help

  • Re: Usercontrol within another usercontrol - ajax unknown server tag

    06-20-2007, 3:50 AM
    • Loading...
    • abunet
    • Joined on 05-22-2007, 12:22 PM
    • Posts 7

    I've the same problem, purell. did you solve it?

    Thanks

     

  • Re: Usercontrol within another usercontrol - ajax unknown server tag

    06-20-2007, 4:01 AM
    • Loading...
    • WishStar99
    • Joined on 08-05-2006, 12:11 AM
    • VietNam
    • Posts 549

    can you show some your html here?  i can't understand what you're trying to do .... confuse by the way you describe drag ... a small sample will explain it ...

    Aeries' Coders
    Programmers' Forums at Advance Microtech


    Nothing is impossible when it comes to coding.
  • Re: Usercontrol within another usercontrol - ajax unknown server tag

    06-20-2007, 8:33 AM
    • Loading...
    • abunet
    • Joined on 05-22-2007, 12:22 PM
    • Posts 7

    HI,

    Start creating in VS2005 a new C# Project (ASP.NET AJAX Enabled Web Application) called UserControlProblem

    The project has 3 files: Default.aspx WebUserControlParent.ascx WebUserControlChild.ascx.

    WebUserControlChild.ascx ( this is the Web UserControl that contains an UpdatePanel )

    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="WebUserControlChild.ascx.cs" Inherits="UserControlProblem.WebUserControlChild" %>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:Label ID="Label1" runat="server" Text="Sample Text"></asp:Label>
        </ContentTemplate>
    </asp:UpdatePanel>

    WebUserControlParent.ascx ( this is the Web UserControl that contains WebUserControlChild.ascx. In design view, you'll see the content of the UserControl: Sample Text)

    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="WebUserControlParent.ascx.cs" Inherits="UserControlProblem.WebUserControlParent" %>
    <%@ Register Src="WebUserControlChild.ascx" TagName="WebUserControlChild" TagPrefix="uc1" %>
    <uc1:WebUserControlChild id="WebUserControlChild1" runat="server">
    </uc1:WebUserControlChild>

    Default.aspx ( this is the Root page that contains WebUserControlParent.ascx. In design view, you'll see the problem: Error rendering Control - WebUserControlChild1 an unhandled exception occurred Unknown server tag 'asp:UpdatePanel')

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="UserControlProblem._Default" %>

    <%@ Register Src="WebUserControlParent.ascx" TagName="WebUserControlParent" TagPrefix="uc1" %>

    <!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 runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
            <asp:ScriptManager ID="ScriptManager1" runat="server" />
        <div>
            <uc1:WebUserControlParent id="WebUserControlParent1" runat="server">
            </uc1:WebUserControlParent></div>
        </form>
    </body>
    </html>

     

  • Re: Usercontrol within another usercontrol - ajax unknown server tag

    06-21-2007, 9:11 AM
    • Loading...
    • abunet
    • Joined on 05-22-2007, 12:22 PM
    • Posts 7

    WishStar99,

    Any news on the example I've posted? (it's very quickly to reproduce)

    Thanks

  • Re: Usercontrol within another usercontrol - ajax unknown server tag

    06-21-2007, 1:27 PM
    • Loading...
    • WishStar99
    • Joined on 08-05-2006, 12:11 AM
    • VietNam
    • Posts 549

    hello,

    sorry to come back late ... i copied your sample and it runs fine on my system.

    1) Create a brand new Ajax Web
    2) Create two Web User Controls
    3) Copied all your HTML above ...
    4) Run default.aspx ... on screen: Simple Text

    here's my files details:

    Default.aspx: 
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
    <%@ Register Src="WebUserControlParent.ascx" TagName="WebUserControlParent" TagPrefix="uc1" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
            <asp:ScriptManager ID="ScriptManager1" runat="server" />
            
    		<uc1:WebUserControlParent id="WebUserControlParent1" runat="server" />
    
        </form>
    </body>
    </html>
    

     WebUserControlChild.ascx:

    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="WebUserControlChild.ascx.cs" Inherits="WebUserControlChild" %>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:Label ID="Label1" runat="server" Text="Sample Text"></asp:Label>
        </ContentTemplate>
    </asp:UpdatePanel>
    

     

    WebUserControlParent.ascx:

     

    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="WebUserControlParent.ascx.cs" Inherits="WebUserControlParent" %>
    <%@ Register Src="WebUserControlChild.ascx" TagName="WebUserControlChild" TagPrefix="uc1" %>
    <uc1:WebUserControlChild id="WebUserControlChild1" runat="server">
    </uc1:WebUserControlChild>

     

    Aeries' Coders
    Programmers' Forums at Advance Microtech


    Nothing is impossible when it comes to coding.
  • Re: Usercontrol within another usercontrol - ajax unknown server tag

    06-25-2007, 2:52 AM
    • Loading...
    • abunet
    • Joined on 05-22-2007, 12:22 PM
    • Posts 7

    The problem is in the VS 2005 Designer not a runtime.

    If you execute he web project every works fine. If you open vs2005 and then default.aspx in desgin view you'll see the render error.

  • Re: Usercontrol within another usercontrol - ajax unknown server tag

    11-15-2007, 2:26 PM

    purell:

    I have an updatepanel on 1.ascx - i drag that over to 2.ascx (that doesn't have any updatepanels).  Then I drag 2.ascx to main.aspx.  main.aspx doesn't recognize the updatepanel from 1.ascx.  If I drag 1.ascx to main.aspx it works.  But I need to have two layers.

    Help

     

    I was able to fix a similar issue by following these steps:

    1) switch to Source view in the Designer

    2) cut all the content except for the Control tag (ctrl-x)

    3) switch to Design view (this seems to clear out all the system generated code)

    4) switch back to Source view

    5) paste all content back onto the page

    6) switch to Design view (this will regenerate all system generated code)


    I did this on whatever pages or controls were giving me "rendering errors" and it seemed to alleviate the issue.  They come back once in a while, but the above steps usually clear them up.

     

  • Re: Usercontrol within another usercontrol - ajax unknown server tag

    11-16-2007, 3:06 AM
    • Loading...
    • abunet
    • Joined on 05-22-2007, 12:22 PM
    • Posts 7

    Thanks for the response,

    but it doesn't work...

     

  • Re: Usercontrol within another usercontrol - ajax unknown server tag

    11-16-2007, 9:29 AM

    abunet:

    Thanks for the response,

    but it doesn't work...

     

     

     

    Try saving the page after steps 2 & 5...  I had to do it a few times before it caught my changes.  If that doesn't work, your situation must be slightly different than mine, sorry.
     

  • Re: Usercontrol within another usercontrol - ajax unknown server tag

    12-11-2007, 6:40 AM
    • Loading...
    • sbyard
    • Joined on 03-26-2003, 3:42 AM
    • North Yorkshire - England
    • Posts 1,172

    Issue still exists in the VS008 RTM too

    If it was easy, everybody would be doing it.
  • Re: Usercontrol within another usercontrol - ajax unknown server tag

    04-29-2008, 10:09 PM
    • Loading...
    • dizzy0ny
    • Joined on 04-29-2008, 4:16 AM
    • Posts 21

    I having a similar issue with VS2005sp1 and .NET 3.0/ASP.NET2.0.

    I have a master page which defines content place holders: HeaderPane, NavBarPane, RightPane, CenterPane, ActionFooterPane, FooterPane

    I have my default page which overrides the Right and Center pane.

    I created a custom control consisting of a table with the rows. no code was added yet as i am just testing the look and feel.

    In design view, i drop an UpdatePanel in the Right Pane and that shows up fine.  I then drag my custom control into the UpdatePanel control and i see the error: "Error Rendering Control...Request is not available in this context".

    I then removed the UpdatePanel and dragged the custom control onto the RightPane content area by itself and still see the error.

    I followed the step of cutting out the code from my Default.aspx page, switching to design view, back to source view and pasting the html back, but to no avail.  When i switch back to design view i still see the error.

    Now what is interesting is when i run the project (based on a post above that suggests this is a design time issue), i see the following error:

    You can only have one <head runat="server"> control on a 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: You can only have one <head runat="server"> control on a 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): You can only have one <head runat="server"> control on a page.]
       System.Web.UI.HtmlControls.HtmlHead.OnInit(EventArgs e) +1925769
       System.Web.UI.Control.InitRecursive(Control namingContainer) +321
       System.Web.UI.Control.InitRecursive(Control namingContainer) +198
       System.Web.UI.Control.InitRecursive(Control namingContainer) +198
       System.Web.UI.Control.InitRecursive(Control namingContainer) +198
       System.Web.UI.Control.InitRecursive(Control namingContainer) +198
       System.Web.UI.Control.InitRecursive(Control namingContainer) +198
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +834

    Any ideas on what this means?

  • Re: Usercontrol within another usercontrol - ajax unknown server tag

    04-30-2008, 1:15 AM
    • Loading...
    • dizzy0ny
    • Joined on 04-29-2008, 4:16 AM
    • Posts 21

    I figured out that my problem was that in my control aspx file, i had a HEAD element as follows:

    <head id="Head1" runat="server">
           <link type="text/css" rel="stylesheet" href="../../../App_Themes/Control.css" />
    </
    head>

     Changing removing the head element and leaving the <link> element almost solved my problem.  The issue i have now is when this control is dragged to my Default.aspx web page, the css styling is not applied.  If i add a reference to it in that page itself (even though there is a link to it in the control already), it still can't find it.  i am certain the path is correct as the Default page is able to pick up other styles from the CSS stylesheet defined in the master page.  Any advice on this issue?

  • Re: Usercontrol within another usercontrol - ajax unknown server tag

    04-30-2008, 10:24 AM

    Use ScriptMangerProxy...  

    <asp:ScriptManagerProxy runat="server" id="SMProxy" />

  • Re: Usercontrol within another usercontrol - ajax unknown server tag

    05-08-2008, 5:18 PM
    • Loading...
    • blumonde
    • Joined on 03-11-2006, 3:45 PM
    • US
    • Posts 376

    Delete the problematic ajax control. Save your file. Drag the same control from the toolbox to replace it. It worked for me.

    Cheers
    no pain no gain