client side ?

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
your button is probably posting back, causing the page to re-render.

-- bruce (sqlwork.com)
 
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
 
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.
 
<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
 
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

Similar Threads

client vs server side 3
client and server 3
client side 5
TextBox1 value 9
background image not showing in designer 1
Force client refresh after site update. How to? 4
validation 2
client side 2

Back
Top