Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Client Side Events on Server Controls?

Status
Not open for further replies.

marcusw

Programmer
Jan 18, 2001
35
GB
Hi Everyone,

I'm currently tearing my hair out trying to understand the following....

My application uses a server side button to do a final page submit. No problem with that! However, does every single event HAVE to run on the server? I would like to have mouseover events that simply change the colour of my button but I don't want a round-trip to the server to achieve this each time I move my mouse onto the button.

Can anyone help please.... I'm sure there is a simple answer but all the help says that it will do a round-trip?

Essentially, is it possible to have Client-Side Javascript for server side controls?

Cheers,

Marcus.
 
To quote a line from the Offspring song Original Prankster (I think):

YOU CAN DO IT!

In the code behind, there's a sub called Web Form Something Something (ugh...where's that coffee?!). Anyway, inside there's a sub called Initialize. Add this line in there:

cmdButton.Attributes.Add("onMouseOver", "javascript:code to change the color")

then, when the page gets loaded, it'll automatically include that "onMouseOver" attribute in the buttons tag.
voila!

This can be used for pretty much any javascript. I use it alot if I need a button to open a new window.

hth

jack
 
yes that is Original Prankster That'l do donkey, that'l do
[bravo] Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top