Show asp:Panel stored in different file

249 Views Asked by At

I have an asp page (.aspx) page, and a asp:Panel in it. I use Telerik library but this is irrelevant, I think.

I now need to move the asp:Panel tag outside the main file, into another, stand-alone, .aspx due to file size and work organization.

I moved the aspx content to a new file, and related code in .cs file, separated from the principal one.

On the load_page of the main one I instantiate, through the constructor, the separate panel - the constructor instantiates every control in the panel, especially the , which has the method .Show().

Every member work in the new class, but since I am very new in ASP I do not know how to put the separate aspx code in the former file, since when I call myModalPopup.Show() I have the only effect of a page reload

Extract of panel in separate file:

<asp:Panel ID="panelId" runat="server">
    <asp:HiddenField ID="control1" runat="server" />
    <ajax:ModalPopupExtender ID="extId" runat="server" TargetControlID="control1">
    </ajax:ModalPopupExtender>
    //Html/Controls stuff
</asp:Panel>

The myPanel.cs

protected EditPanel myPanel = new EditPanel();
public class EditPanel: System.Web.UI.Page
{
    protected Panel myPanel;
    protected HiddenField control1;
    public AjaxControlToolkit.ModalPopupExtender extender;
    //Other controls

    public EditPanel()
    {
        extender = new AjaxControlToolkit.ModalPopupExtender();
        control1 = new HiddenField();
        //Other inits
    }
}

In main page .cs:

protected void Page_Load(object sender, EventArgs e)
{
    protected EditPanel editor = new EditPanel();
    //... so on 
}

In main page.aspx I tried (without success)

<asp:Panel ID="panelId" runat="server">
<!-- #Include virtual="~/path/EditPanel.aspx" -->
</asp:Panel> 
0

There are 0 best solutions below