Auto PostBack

H

Henri

On a websitye, I have a webfom, with a Image and a RadioButtonList.
When a user selects an item in the RadioButtonList, the property "ImageUrl"
of the Image changes.
If the property "AutoPostBack" of the RadioButtonList is at FALSE, changing
the item don't change the image.
If the property "AutoPostBack" is at TRUE, when the user change an item, the
image is changed, but all the page is reloaded.
How can I do to refresh only the image and not all the page ?
Many thanks for your answer.
Henri
 
N

Nathan Sokalski

My recommendation would be to use AJAX, but you might also be able to fix
your problem by changing the EnableViewState property. Good Luck!
 
T

ThunderMusic

hi,
actually, no ajax needed (sorry Nathan)... javascript usually does the job
in this kind of situation... though you'll have to do some job server side
prior to displaying your page at once, it's pretty seemless afterward...
here's an exemple of a resulting html :

<html><head>whatever is your html head</head>
<body>
<script>
function changeImage(imageURL) {
var imgctl = document.getElementById('imgToChange');
imgctl.src = imageURL;
}
</script>
<p><img src="Whatever url" id="imgToChange" name="imgToChange" /></p>
<p>
<input type="radio" onclick="changeImage('an other url');" />some text<br>
<input type="radio" onclick="changeImage('an other url');" />some other
text<br>
<input type="radio" onclick="changeImage('an other url');" />still some
other text<br>
</p>
</body>
</html>

Actually, what you will need to do is add an OnClick event on each of your
elements to display the right image... I think it's pretty straight forward
and it works in all the browsers (well, I'm pretty sure)

I hope it helps

ThunderMusic
 
K

Keith Patrick

HTTP generally involves an entire page being refreshed. Your alternatives
to refreshing an entire page are to either load all the images into hidden
(style.display = 'none') and show them or insert nodes into the DOM tree via
Javascript, or turn on ASP.Net SmartNavigation, which loads the entire
response into a hidden iframe, DIFFs the two DOMs, and inserts the
appropriate node from the iframe into the unrefreshed page, giving the
appearance of a partial postback.
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top