简体   繁体   中英

How to load content of child page into div in asp.net c#

I need to load content of child page-1 into div of child page-2. I have tried to load the content using jquery, but it loads entire page including master page. I want to load only child page content excluding master page content. Is there any way to do this?

I am betting that you have jQuery available here.

So, to load a page - even one that was setup as a child to a master page?

this works quite well:

<asp:Button ID="Button1" runat="server" Text="Button"  OnClientClick="getpage();return false"   />

<div id="myotherpage">
</div>

<script>
    function getpage() {
        alert('hello');
        $.get("/WebForm5.aspx", function (data) {
            $("#myotherpage").html(data);
        });
    }
</script>

So, in above, I want to get/grab/load the WebForm5.aspx page right into that div.

In this example, EVEN if WebForm5.aspx WAS attached to master, the above seems to work rather nice.

The other way? Well of course the iFrame idea - that works. (but a iFrame would also re-produce the menu bar - the above does not).

but, above does work quite nice - even the code behind for that page seems to run just fine.

Now, I just dropped in a button - you click on it, and it does load the other page into the div - but you can have that js code run on page load - say document ready, or even just place the above code in the script not wrapped in a function.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM