client side ?

G

Guest

hey all,

i have a html image with style.visibility:hidden.
i have a button running client-side script to make the image
style.visibility:visible

however, when i click the button it displays the image real fast and then
disappears again. can someone please explain this to me?

thanks,
rodchar
 
B

Bruce Barker

your button is probably posting back, causing the page to re-render.

-- bruce (sqlwork.com)
 
K

Karl Seguin

The button is posting back and causing the page to get re-requested.
Client-side set attributes aren't preserved during postback.

If you want the postback to happen, you'll need to detect the postback and
set the image style before render.

If you don't want the postback, perhaps use an HtmlInputButton instead of a
WebControls.Button or something...
Karl
 
G

Guest

If you use a server-side <asp:button> rather than a client-side, HTML <input
type="button"> then clicking the button makes a round trip to the server and
reloads your page, thus resetting the defaults.

Use an HTML button.
 
G

Guest

<script language="javascript">
function fillin()
{
document.getElementById("Image1").style.visibility="visible"
}
</script>

<TD><IMG id="Image1" alt="" src="loading.gif" style="VISIBILITY: hidden"></TD>

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.Button1.Attributes.Add("onClick", "fillin();")
End Sub
 
D

Daniel Walzenbach

Rodchar,

if you click the button your js fires and makes the image visible but the a
postback appears which will result in the image beeing hidden again.

Does this make sense?

Daniel
 

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,774
Messages
2,569,596
Members
45,143
Latest member
SterlingLa
Top