usercontrol refresh

R

Rob Koch

What's the best way to refresh a usercontrol using a parameter? My
usercontrol is just a DataList that retrieves data from SQL in association
with a public propterty.

I click on a LinkButton in my main page (ASPX), but it still refreshes the
entire page... I only want the UserControl to blink and come back with new
data.

What's the direction I should be looking at? Even if I do it via
JavaScript, how would I refresh the UserControl using JavaScript?

TIA,
-roko
 
T

Tim S.

My hunch is that this is not possible. Here's why:
1 - JavaScript cannot trigger anything on the server. UC
are run at the server. Therefore JS alone could not
trigger anything for a UC to refresh.

2 - UC ultimately get generated into regular HTML that is
merged with the rest of your page, just look at the view
source HTML from your browser. To re-generate the UC
requires re-generating the entire page.

In terms of solutions, would caching help out? Perhaps
putting the UC in a sub-frame so that it still has its own
page that refreshes?

HTH,
Tim Stall
 
R

Rob Koch

As a quick fix, what I did was load all those UCs that I need (3 images with
links vertically on the right side), enclosed them all within their own div
tags. So for 4 user controls, I have them all enclosed in 4 div tags. I
used javascript to show/hide these div tags, i.e.
document.getElementById("uc1").style.display = 'block'); or
document.getElementById("uc1").style.display = 'none');

I found this method thanks to this link:
http://www.webmatrixproject.net/Forums/ShowPost.aspx?tabindex=1&PostID=21175

As it is done, three images shows up in the UC (as there's only enough room
for it), but if I was to do some pagination in that datalist of images, I
think I will be stuck, but otherwise, I'm OK for the time being...

Still not a be-all, end-all solution, but worth working towards... :)

-roko
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,778
Messages
2,569,605
Members
45,238
Latest member
Top CryptoPodcasts

Latest Threads

Top