0

I am a beginner in asp.net.I have Web application project in ASP.NET. This project consists of several sub-projects. I want to make a Home page (or main page) in the project with several tabs and the active tab has the home page (or main page) of the sub-project. As I click the other tab,respective home page of a sub-project should load.

Can it be done in ASP.NET? I have searched the web. I have got related solutions. I am not sure how I can load a page inside another without using frames.

Will really appreciate the help.Please pardon my ignorance if I have missed some post addressing my problem.

Thanks in advance.

Ravi Joisher
  • 81
  • 1
  • 3

1 Answers1

0

This can be done with Javascript and AJAX. What you do, is make sure your server can handle a GET request, so it returns the content for the page you want to show. I have no experience in ASP.NET myself, but plenty in PHP and their purpose is the same. A quick search about ASP.NET requests brought me to this link: How to handle C# .NET GET / POST?

What you do in your client app, is make a callback when a button is clicked. Then you start a GET request to the server.

xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
    if( xhr.readyState===4 ) {
        // You got the content!
    }
}.bind(this);
xhr.open( "GET", 'page url', true );
xhr.send();

There is also a very useful function for this in jQuery: http://api.jquery.com/jQuery.ajax/

The content you get from the GET request should go inside the element where you want the content to be shown.

contentDiv.innerHTML = xhr.responseText;

Or with jQuery:

$('#content').html(xhr.responseText);

Please remember that you will have to check for 404 not found errors both client sided and server sided.

I hope this will give you an indication of where to start. Good luck!

Community
  • 1
  • 1
Aart Stuurman
  • 3,188
  • 4
  • 26
  • 44