1

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> 
4
  • Please share with us what you coded so far, we can help better Commented Jul 4, 2016 at 17:10
  • 2
    You don't need another aspx file. Create an ascx control and call it from the form. Commented Jul 4, 2016 at 17:21
  • I did as you suggest, all moved in an ascx - yet I cannot obtain the panel to be shown when I do .Show(). I inserted the control in the parent with its class tag <Namespace:MyPanel>. Note: the parent is also an ascx. Commented Jul 5, 2016 at 8:42
  • I am unsure what you are trying to achieve and what the issue is, but perhaps the FindControl method may be useful when you are trying to obtain control references. Commented Jul 5, 2016 at 10:51

0

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.