How to display an ASPX in another ASPX's DIV dynamically at runtime?

前端 未结 5 1627
予麋鹿
予麋鹿 2020-12-17 18:52

Here is what I am trying to do in ASP.NET:

Create one page called Main.aspx. This page has a DIV and a buttons.

The browser loads Main.aspx. Then when I clic

5条回答
  •  醉酒成梦
    2020-12-17 19:44

    If you're using the AJAX toolkit it should be possible to do this using a webcontrol rather than an ASPX page.

    If you try to pursue this idea using ASPX pages, and without using an iframe, you will find that there is no isolation provided for javascript variable names and element ids, therefore almost guaranteeing conflicts if you put the rendered aspx's content into a div using innerHTML; The page will definitely not be able to perform a partial postback as I imagine you would like.

    Using a webcontrol instead: A better solution would be to install the AJAX toolkit if you haven't already, and use an updatepanel control. Either dynamically load and unload webcontrols inside this panel (using LoadControl()), or place a Multiview control inside it and change the activeview to simulate changing this content.

    The updatepanel will allow its contents to update without a full postback (page refresh).

提交回复
热议问题