Rocks
Rocks

Reputation: 11

Is it possible to reference same ascx user control within the same ascx control

Is it possible to use/reference same ascx user control within the same ascx control? Primarily we want a popup within a popup within a popup - n level based on a condition. The popup is the user control.

Upvotes: 1

Views: 148

Answers (2)

Aghilas Yakoub
Aghilas Yakoub

Reputation: 29000

You can not : Circular file references are not allowed.

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="WebUserControl1.ascx.cs" Inherits="WebApplication1.WebUserControl1" %>
<%@ Register TagPrefix="test" TagName="test" Src="~/WebUserControl1.ascx"%>

This code is not possible

Upvotes: 0

M4N
M4N

Reputation: 96606

I guess this is possible when loading/adding the control programmatically, e.g:

this.Controls.Add(LoadControl("~/mycontrol.ascx"));

But if you do this unconditionally, then you'll get an endless loop.

Upvotes: 1

Related Questions