Re: trouble with rollover buttons on master page
- From: "Keith G Hicks" <krh@xxxxxxxxxxx>
- Date: Thu, 27 Mar 2008 18:57:10 -0500
Well I figured something out. I'd still love to know why all the things
below don't work but here's what is more important now. If I use an
asp:Imagebutton and do this:
<asp:ImageButton
ID="ImageButton1"
runat="server"
ImageUrl="~/RolloverButtonsImages/button3up.png"
onmouseover="this.src='~/RolloverButtonsImages/button3over.png'"
onmouseout="this.src='~/RolloverButtonsImages/button3up.png'">
</asp:ImageButton>
I know why the above does not work. The tilde in the "this.src..." does not
get calculated in the page source. I did a view source and asp does not
resolve the tilde. I think I know why but I have no idea how to write the
above so that it DOES work. I tried several variations but got nowhere. If I
take out the tilde and hard code the root, it does work but then I'm back to
my original problem where I don't want to hard code the root.
Thanks,
Keith
"Keith G Hicks" <krh@xxxxxxxxxxx> wrote in message
news:uiSpE4CkIHA.944@xxxxxxxxxxxxxxxxxxxxxxx
OK. Thanks Bruce. Your explanation about the tilde and runat="server"helped
a lot. But I'm lost on the other end.course
Given the code shown below, here's what happens. All the buttons show up
when loading the page. They show up with the "out" image which is of
correct. When I click one of them it directs to the correct page. That'stilde
fine so far. They also show up and click to the correct pages as expected
when I'm viewing a page that's in a subfolder. So far so good. But the
rollover doesn't do anything. I don't get the "over" image at any time. No
errors, no funny behavior, just no image change.
There are 3 things shown below.
1 - the contents of a javascript file that's supposed to change the
images.
2 - the contents of my masterpage head section.
3 - one of the button definitions.
Here's the contents of the javascript file (which was created by a button
generating tool). The file is named RolloverButtonsImagesMenuScript.js and
is in the root. Notice the first line is var buttonFolder =
"~/RolloverButtonsImages/"; with the tilde (I've tried it without the
as well and other variations I could think of too). I know this code worksArray("button1up.png","button2up.png","button3up.png","button4up.png","butto
generally because when I had this running on my development machien I had
hard coded the root folder name into just about everything. But when I got
to the remote server, things fell apart and I realized that was a mistake.
So here I am.
/*############### js file code begins here ###################*/
/*** SET BUTTON'S FOLDER HERE ***/
var buttonFolder = "~/RolloverButtonsImages/";
/*** SET BUTTONS' FILENAMES HERE ***/
upSources = new
n5up.png","button6up.png","button7up.png","button8up.png","button9up.png","b
utton10up.png","button11up.png");Array("button1over.png","button2over.png","button3over.png","button4over.png
overSources = new
","button5over.png","button6over.png","button7over.png","button8over.png","b
utton9over.png","button10over.png","button11over.png");follows:
//*** NO MORE SETTINGS BEYOND THIS POINT ***//
totalButtons = upSources.length;
//*** MAIN BUTTONS FUNCTIONS ***//
// PRELOAD MAIN MENU BUTTON IMAGES
function preload() {
for ( x=0; x<totalButtons; x++ ) {
buttonUp = new Image();
buttonUp.src = buttonFolder + upSources[x];
buttonOver = new Image();
buttonOver.src = buttonFolder + overSources[x];
}
}
// SET MOUSEOVER BUTTON
function setOverImg(But, ID) {
document.getElementById('button' + But + ID).src = buttonFolder +
overSources[But-1];
}
// SET MOUSEOUT BUTTON
function setOutImg(But, ID) {
document.getElementById('button' + But + ID).src = buttonFolder +
upSources[But-1];
}
//preload();
/*############### js file code ends here ###################*/
In the HEAD section of my master page I have this:
<head runat="server">
<title>Untitled Page</title>
<script src="RolloverButtonsImagesMenuScript.js" language="javascript"
type="text/javascript"></script>
<link rel="SHORTCUT ICON" href="favicon.ico">
</head>
Finally, one of the buttons is defined in the master page markup as
<a runat="server" href="~/Default.aspx" onmouseover="setOverImg('1','');"
onmouseout="setOutImg('1','');" target=""> <img runat="server"
src="~/RolloverButtonsImages/button1up.png" border="0" id="button1"
vspace="1" hspace="1"></a><br>
Hope you can help a little more.
Thanks,
Keith
.
- Follow-Ups:
- Re: trouble with rollover buttons on master page
- From: Keith G Hicks
- Re: trouble with rollover buttons on master page
- References:
- trouble with rollover buttons on master page
- From: Keith G Hicks
- Re: trouble with rollover buttons on master page
- From: bruce barker
- Re: trouble with rollover buttons on master page
- From: Keith G Hicks
- trouble with rollover buttons on master page
- Prev by Date: RE: Does AJAX just require 2.0 Framework
- Next by Date: RE: Does AJAX just require 2.0 Framework
- Previous by thread: Re: trouble with rollover buttons on master page
- Next by thread: Re: trouble with rollover buttons on master page
- Index(es):