×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Javascript DIV and visibility style

Javascript DIV and visibility style

Javascript DIV and visibility style

(OP)
I got a weird effect firing off a JS event on a onClick event in vb.net.

I have this line in my html:

<div align="center" id="divPleaseWait" style="VISIBILITY:hidden">Please Wait</div>

Then this in .vb to make it active:

dlMeters.Attributes.Add("onClick", "JavaScript:doPleaseWait();")

The function doPleaseWait does this:

function doPleaseWait(){
   document.getElementById('divPleaseWait').style.visibility = 'visible';
}

However on any of the buttons/links/datalists I add this event to, the first click doesn't make the text in div tag appear, however, every click thereafter on the same button/link/datalist works fine.

Whats going on?

RE: Javascript DIV and visibility style

It will be because you are adding it (I guess) on the click event of a button. For example,

1) You click an .NET server control (a button)
2) The page loads
3) The button event fires and adds the onclick event

When you next click the button, the event exists and therefore fires but the first time you clicked it it didn't exist and so didn't fire. Make sense?

--------------------------------------------------------------------------------------------------------------------------------------------

Need help finding an answer?

Try the search facility (http://www.tek-tips.com/search.cfm) or read FAQ222-2244 on how to get better results.

RE: Javascript DIV and visibility style

(OP)
RIght, that makes sense, so do I need to retgister the script someway before the page loads?

RE: Javascript DIV and visibility style

Basically if you want an event to fire it has to be added on the Page Load.

There are several ways to do it such as Page.RegisterStartupScript, Page.RegisterClientScriptBlock or even just making sure you add the Attributes on the Page Load itself.

--------------------------------------------------------------------------------------------------------------------------------------------

Need help finding an answer?

Try the search facility (http://www.tek-tips.com/search.cfm) or read FAQ222-2244 on how to get better results.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close