Timsen
Timsen

Reputation: 4126

On button click load UserControl without refreshing whole page

Explaining my problem:

In my ASP.NET solution i have 2 buttons:

Button 1 and Button 2

I have two UserControls with totally different content

OnClick of each of those buttons i want to load different UserControl into ContentPlaceHolder, but without reload whole page. So actually it have to work like Ajax TabContainer (but without loading all tabs at once).

I have tried to solve this problem with Ajax TabContainers, but loading times was just awful.

Anyone had same problem? How do u solve this one guys?

Upvotes: 1

Views: 1232

Answers (1)

Lil' Bits
Lil' Bits

Reputation: 898

ContentPlaceHolder I'm assuming is a div

You can use the .load() jQuery method. This will load contents of a page into a container via an AJAX call, without refreshing the page.

Used like this:

$('#button1').click(function(){
    $('#ContentPlaceHolder').load('ajax/test1.php');
});

$('#button2').click(function(){
    $('#ContentPlaceHolder').load('ajax/test2.php');
});

Upvotes: 1

Related Questions