Help with a default page

G

Goober

I have the following default.aspx page that works properly.

However, what I want to do is to link the graphics within it (that are hard
coded now in the default web page) to our corporate website, which has the
same graphics rotated on a 30 day basis or so. They have a standard naming
convention where I know the 3 graphics are always going to be fa_mmyy.jpg,
am_mmyy.jpg, and ax_mmyy.jpg.

The HTML follows:

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="default.aspx.vb"
Inherits="mywebapp._default" %>
<HTML>
<HEAD>
<title>mycompany Sales Information System</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
<LINK href="common.css" type="text/css" rel="stylesheet">
</HEAD>
<body text="#000000" bgColor="#ffffff">
<form id="Form1" method="post" runat="server">
<table cellSpacing="0" cellPadding="0" width="770" align="left"
border="0">
<tr>
<td style="HEIGHT: 112px" vAlign="top" align="left" height="112">
<table cellSpacing="0" cellPadding="0" width="100%" border="0">
<tr>
<td width="353"><IMG style="WIDTH: 572px; HEIGHT: 69px" height="69"
src="Images\mycompanyLogo.bmp" width="572"></td>
<td vAlign="top" align="left" width="270">
<table cellSpacing="0" cellPadding="0" width="100%" border="0">
<tr>
<td height="8"></td>
</tr>
<tr>
<td background="images/bg1.jpg" height="18">
<div class="links" align="center"><A class="links"
href="#"><FONT color="green">Home</FONT></A><FONT color="green">
|&nbsp; </FONT><A class="links" href="#"><FONT
color="green">FAQ</FONT></A><FONT color="green">
| </FONT><A class="links" href="#"><FONT
color="green">Contact</FONT></A></div>
</td>
</tr>
<tr>
<td height="43">&nbsp;
<asp:image id="Image1" runat="server" Width="160px"
ImageUrl="Images/mywebappLogo.bmp"></asp:image></td>
</tr>
</table>
</td>
</tr>
</table>
<P align="center"><STRONG><FONT face="Verdana" color="green">mycompany
Arms Sales
Information System</FONT></STRONG>
</P>
</td>
</tr>
<tr>
<td>
<table cellSpacing="0" cellPadding="0" width="100%" border="0">
<tr>
<td style="WIDTH: 288px" width="288"><IMG height="100"
src="http://www.mywebsite.com/images/splash/fi_0904.jpg" width="200"></td>
<td style="WIDTH: 147px" width="147"><IMG height="100"
src="http://www.mywebsite.com/images/splash/am_0904.jpg" width="200"></td>
<td width="151"><IMG height="100"
src="http://www.mywebsite.com/images/splash/ax_0904.jpg" width="200"></td>
<td vAlign="top" align="left" width="169" bgColor="green">
<table cellSpacing="5" cellPadding="0" width="100%" border="0">
<tr>
<td class="heading" height="15"><FONT color="#ffffff">Member
Login</FONT></td>
</tr>
<tr>
<td>
<table cellSpacing="1" cellPadding="0" width="100%"
bgColor="green" border="0">
<tr>
<td>
<table height="114" cellSpacing="3" cellPadding="1"
width="100%" bgColor="#ffffff" border="0">
<tr>
<td>
<table cellSpacing="0" cellPadding="0" width="100%"
border="0">
<tr>
<td width="46%"><span class="text">User ID</span></td>
<td width="54%">&nbsp;
<asp:textbox id="txtUser" runat="server"
CssClass="formfield"></asp:textbox></td>
</tr>
<tr>
<td class="text" width="46%">Password</td>
<td width="54%">&nbsp;
<asp:textbox id="txtPassword" runat="server"
CssClass="formfield" TextMode="Password"></asp:textbox></td>
</tr>
</table>
<asp:label id="Msg" runat="server" CssClass="text"
Width="136px" ForeColor="Red"></asp:label></td>
</tr>
<tr>
<td>
<div align="center"><asp:button id="btnSubmit"
runat="server" CssClass="botlinks" Font-Bold="True" ForeColor="White"
Text="Submit"></asp:button></div>
</td>
</tr>
<tr>
<td>
<div class="links" align="center"><A class="links"
href="password.aspx">Change Password</A>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="HEIGHT: 18px" bgColor="#ffffff" height="18"></td>
</tr>
<tr>
<td bgColor="green" height="33">
<table cellSpacing="0" cellPadding="0" width="100%" border="0">
<tr>
<td width="300">
<table cellSpacing="6" cellPadding="0" width="100%" border="0">
<tr>
<td width="10%">&nbsp;</td>
<td width="10%"><IMG height="16" src="images/braill.gif"
width="20"></td>
<td class="headlinks" width="80%"><A class="headlinks"
onmouseover="showit(0)" href="#">mycompany
Links</A></td>
</tr>
</table>
</td>
<td><IMG height="33" src="images/dit1.jpg" width="1"></td>
<td width="149">
<table cellSpacing="6" cellPadding="0" width="100%" border="0">
<tr>
<td width="10%">&nbsp;</td>
<td width="10%"><IMG height="16" src="images/braill.gif"
width="20"></td>
<td class="headlinks" width="80%"><A class="headlinks"
onmouseover="showit(1)" href="#">Industry
Links</A></td>
</tr>
</table>
</td>
<td><IMG height="33" src="images/dit1.jpg" width="1"></td>
<td width="149"></td>
<td><IMG height="33" src="images/dit1.jpg" width="1"></td>
<td width="169"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="1"></td>
</tr>
<tr>
<td bgColor="#d5dcdc" height="18">
<DIV id="describe" onmouseover="clear_delayhide()" style="WIDTH:
770px; HEIGHT: 14px; BACKGROUND-COLOR: #d5dcdc"
onmouseout="resetit(event)"></DIV>
<SCRIPT language="JavaScript1.2">
var submenu=new Array()

//Set submenu contents. Expand as needed. For each content, make sure
everything exists on ONE LINE. Otherwise, there will be JS errors.

submenu[0]='<table width="100%" border="0" cellspacing="0"
cellpadding="0"><tr><td width="8%">&nbsp;</td><td width="92%"><a
href="http://www.mycompany.com" class="links">mycompany</a> | <a
href="http://www.mycompanyle.com/" class="links">Law Enforcement</a> | <a
href="http://www.mycompanymilitary.com/" class="links">Military</a> | <a
href="http://www.rempac.org/" class="links">REMPAC</a> | <a
href="http://www.mycompanypmpd.com/" class="links">PMPD</a> | <a
href="http://www.mycompany.com/login/customer_login?NEXTURL=/partner/def
ault%2Ehtm" class="links">Partner</a> | </td></tr></table>'
submenu[1]='<table width="100%" border="0" cellspacing="0"
cellpadding="0"><tr><td width="23%">&nbsp;</td><td width="77%"><a
href="default.aspx?P=1" class="links">Organizational</a> | <a
href="default.aspx?P=2" class="links">Historical</a> | <a href="#"
class="links"><a href="default.aspx?P=3" class="links">Link1</a> | <a
href="default.aspx?P=4" class="links">Link2</a> | <a href="default.aspx?P=5"
class="links">Optics</a> | <a href="default.aspx?P=6"
class="links">Accessories</a> | <a href="default.aspx?P=8"
class="links">Hunting</a> | <a href="default.aspx?P=9"
class="links">Other</a> | <a href="default.aspx?P=10"
class="links">Sales</a></td></tr></table>'
submenu[2]='<table width="100%" border="0" cellspacing="0"
cellpadding="0"><tr><td width="61%">&nbsp;</td><td width="39%"><a href="#"
class="links">e-Signature Bill</a> | <a href="#" class="links">Digital
Document</a></td></tr></table>'
submenu[3]='<table width="100%" border="0" cellspacing="0"
cellpadding="0"><tr><td width="65%">&nbsp;</td><td width="35%"><a href="#"
class="links">News &amp; Events</a> | <a href="#" class="links">Policy
Alert</a> | <a href="#" class="links">Did You Know?</a></td></tr></table>'
//Set delay before submenu disappears after mouse moves out of it (in
milliseconds)
var delay_hide=300

/////No need to edit beyond here

var menuobj=document.getElementById? document.getElementById("describe") :
document.all? document.all.describe : document.layers?
document.dep1.document.dep2 : ""

function showit(which){
clear_delayhide()
thecontent=(which==-1)? "" : submenu[which]
if (document.getElementById||document.all)
menuobj.innerHTML=thecontent
else if (document.layers){
menuobj.document.write(thecontent)
menuobj.document.close()
}
}

function resetit(e){
if (document.all&&!menuobj.contains(e.toElement))
delayhide=setTimeout("showit(-1)",delay_hide)
else if (document.getElementById&&e.currentTarget!= e.relatedTarget&&
!contains_ns6(e.currentTarget, e.relatedTarget))
delayhide=setTimeout("showit(-1)",delay_hide)
}

function clear_delayhide(){
if (window.delayhide)
clearTimeout(delayhide)
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

</SCRIPT>
</td>
</tr>
<TR>
<TD height="18">
<table cellSpacing="0" cellPadding="0" width="770" align="center"
border="0">
<TR>
<TD>
<P>&nbsp;</P>
<P class="text" align="left">
<asp:Label id="Label2" runat="server" Width="694px"
CssClass="text">The quota system is a new part of the mycompany managements
efforts to improve customer service. This system will provide the ability
to forecast at the sales class level. The tools provided include
forecasting at the customer level by inputting a percent improvement for
each of the business areas.</asp:Label></P>
<P class="text" align="center">
<asp:ListBox id="ListBox1" runat="server" Width="179px"
CssClass="text" DataTextField="name"
DataValueField="url" AutoPostBack="True"></asp:ListBox></P>
<P class="text" align="center"><asp:label id="Label1"
runat="server" Width="304px"></asp:label></P>
<P>&nbsp;</P>
<P>&nbsp;</P>
</TD>
</TR>
</table>
<table cellSpacing="0" cellPadding="0" width="770" align="center"
border="0">
<TR>
<TD>
<DIV align="center"><IMG height="2" src="images/hor_dot.gif"
width="652"></DIV>
</TD>
</TR>
<TR>
<TD height="6"></TD>
</TR>
<TR>
<TD bgColor="green" height="20">
<DIV class="botlinks" align="center"><A class="botlinks"
href="#"><U><FONT color="white">Home</FONT></U></A>
|&nbsp; <A class="botlinks" href="#"><U><FONT
color="white">FAQs</FONT></U></A>
| <A class="botlinks" href="#"><U><FONT color="white">Contact
Us</FONT></U></A></DIV>
</TD>
</TR>
<TR>
<TD height="20">
<DIV class="text" align="center">Copyright 2004. All rights
reserved mycompany Arms</DIV>
</TD>
</TR>
</table>
</TD>
</TR>
</table>
</form>
</body>
</HTML>


What I want to do is the following:

Where the graphics on our corporate website are rotated each month, I want
to construct the filename within this page in order to be able to put the
month & year and develop a link to the corporate website that'd pull the
appropriate graphic over to it, keeping our sales site in synch with the
corporate one.

I kinda know how to do this in VBscript, and have an old ASP page that I
have tested with and know that the code I developed in VBscript is good and
does work like it should.

In my test, where I had the src=".... " statements on those graphics, I was
able to pull in the graphics from the main website, after building the
filename and putting together the URL for the graphic. I had something like
src="<%=filename1%>" and it worked.

However, this new page doesn't like the mixing of the VBscript with the
Javascript that's already on the page.

Is there a way for me to build the following in Javascript that'll work
within the page, and allow me to show those pictures and pull the new ones
as the month & year changes on the website.

testmonth = month(date)
testyear = year(date)
filenameyear = mid(testyear,3)
if testmonth < 10 then
testmonth = "0" & testmonth
end if

firearmsfname = "http://www.mycompany.com/images/splash/fi_" & testmonth &
filenameyear & ".jpg"
ammofname = "http://www.mycompany.com/images/splash/am_" & testmonth &
filenameyear & ".jpg"
accsfname = "http://www.mycompany.com/images/splash/ax_" & testmonth &
filenameyear & ".jpg"

I know the above works in ASP and in conjunction with the
src="<%=filename1%>" in the src part of the IMG tag. However, I know
nothing about Javascript or how to write it or make it execute the same way
that the VBScript would.

How can I write the code above, put it into the html you see above that, and
have both to work?

Any help/advice appreciated,

SC
 
C

Curt_C [MVP]

ok, no one wants THAT much code... basically though you can get this and
pass it to the html with an asp:Label (which is easiest in my opinion)

<asp:Lable id=lblImage1 runat=server></asp:Image>

Then in the code-behind

lblImage1.Text = "<img src=http://www.server.com/ax_" +
System.DateTime.Now.Month + System.DateTime.Now.Year + ".jpg>";

You may have to wrap a small call around the Month & Year if you force 2
digits, but that's no biggie.

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com


Goober said:
I have the following default.aspx page that works properly.

However, what I want to do is to link the graphics within it (that are
hard
coded now in the default web page) to our corporate website, which has the
same graphics rotated on a 30 day basis or so. They have a standard
naming
convention where I know the 3 graphics are always going to be fa_mmyy.jpg,
am_mmyy.jpg, and ax_mmyy.jpg.

The HTML follows:

<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="default.aspx.vb"
Inherits="mywebapp._default" %>
<HTML>
<HEAD>
<title>mycompany Sales Information System</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
<LINK href="common.css" type="text/css" rel="stylesheet">
</HEAD>
<body text="#000000" bgColor="#ffffff">
<form id="Form1" method="post" runat="server">
<table cellSpacing="0" cellPadding="0" width="770" align="left"
border="0">
<tr>
<td style="HEIGHT: 112px" vAlign="top" align="left" height="112">
<table cellSpacing="0" cellPadding="0" width="100%" border="0">
<tr>
<td width="353"><IMG style="WIDTH: 572px; HEIGHT: 69px" height="69"
src="Images\mycompanyLogo.bmp" width="572"></td>
<td vAlign="top" align="left" width="270">
<table cellSpacing="0" cellPadding="0" width="100%" border="0">
<tr>
<td height="8"></td>
</tr>
<tr>
<td background="images/bg1.jpg" height="18">
<div class="links" align="center"><A class="links"
href="#"><FONT color="green">Home</FONT></A><FONT color="green">
|&nbsp; </FONT><A class="links" href="#"><FONT
color="green">FAQ</FONT></A><FONT color="green">
| </FONT><A class="links" href="#"><FONT
color="green">Contact</FONT></A></div>
</td>
</tr>
<tr>
<td height="43">&nbsp;
<asp:image id="Image1" runat="server" Width="160px"
ImageUrl="Images/mywebappLogo.bmp"></asp:image></td>
</tr>
</table>
</td>
</tr>
</table>
<P align="center"><STRONG><FONT face="Verdana"
color="green">mycompany
Arms Sales
Information System</FONT></STRONG>
</P>
</td>
</tr>
<tr>
<td>
<table cellSpacing="0" cellPadding="0" width="100%" border="0">
<tr>
<td style="WIDTH: 288px" width="288"><IMG height="100"
src="http://www.mywebsite.com/images/splash/fi_0904.jpg" width="200"></td>
<td style="WIDTH: 147px" width="147"><IMG height="100"
src="http://www.mywebsite.com/images/splash/am_0904.jpg" width="200"></td>
<td width="151"><IMG height="100"
src="http://www.mywebsite.com/images/splash/ax_0904.jpg" width="200"></td>
<td vAlign="top" align="left" width="169" bgColor="green">
<table cellSpacing="5" cellPadding="0" width="100%" border="0">
<tr>
<td class="heading" height="15"><FONT color="#ffffff">Member
Login</FONT></td>
</tr>
<tr>
<td>
<table cellSpacing="1" cellPadding="0" width="100%"
bgColor="green" border="0">
<tr>
<td>
<table height="114" cellSpacing="3" cellPadding="1"
width="100%" bgColor="#ffffff" border="0">
<tr>
<td>
<table cellSpacing="0" cellPadding="0" width="100%"
border="0">
<tr>
<td width="46%"><span class="text">User ID</span></td>
<td width="54%">&nbsp;
<asp:textbox id="txtUser" runat="server"
CssClass="formfield"></asp:textbox></td>
</tr>
<tr>
<td class="text" width="46%">Password</td>
<td width="54%">&nbsp;
<asp:textbox id="txtPassword" runat="server"
CssClass="formfield" TextMode="Password"></asp:textbox></td>
</tr>
</table>
<asp:label id="Msg" runat="server" CssClass="text"
Width="136px" ForeColor="Red"></asp:label></td>
</tr>
<tr>
<td>
<div align="center"><asp:button id="btnSubmit"
runat="server" CssClass="botlinks" Font-Bold="True" ForeColor="White"
Text="Submit"></asp:button></div>
</td>
</tr>
<tr>
<td>
<div class="links" align="center"><A class="links"
href="password.aspx">Change Password</A>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="HEIGHT: 18px" bgColor="#ffffff" height="18"></td>
</tr>
<tr>
<td bgColor="green" height="33">
<table cellSpacing="0" cellPadding="0" width="100%" border="0">
<tr>
<td width="300">
<table cellSpacing="6" cellPadding="0" width="100%" border="0">
<tr>
<td width="10%">&nbsp;</td>
<td width="10%"><IMG height="16" src="images/braill.gif"
width="20"></td>
<td class="headlinks" width="80%"><A class="headlinks"
onmouseover="showit(0)" href="#">mycompany
Links</A></td>
</tr>
</table>
</td>
<td><IMG height="33" src="images/dit1.jpg" width="1"></td>
<td width="149">
<table cellSpacing="6" cellPadding="0" width="100%" border="0">
<tr>
<td width="10%">&nbsp;</td>
<td width="10%"><IMG height="16" src="images/braill.gif"
width="20"></td>
<td class="headlinks" width="80%"><A class="headlinks"
onmouseover="showit(1)" href="#">Industry
Links</A></td>
</tr>
</table>
</td>
<td><IMG height="33" src="images/dit1.jpg" width="1"></td>
<td width="149"></td>
<td><IMG height="33" src="images/dit1.jpg" width="1"></td>
<td width="169"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="1"></td>
</tr>
<tr>
<td bgColor="#d5dcdc" height="18">
<DIV id="describe" onmouseover="clear_delayhide()" style="WIDTH:
770px; HEIGHT: 14px; BACKGROUND-COLOR: #d5dcdc"
onmouseout="resetit(event)"></DIV>
<SCRIPT language="JavaScript1.2">
var submenu=new Array()

//Set submenu contents. Expand as needed. For each content, make sure
everything exists on ONE LINE. Otherwise, there will be JS errors.

submenu[0]='<table width="100%" border="0" cellspacing="0"
cellpadding="0"><tr><td width="8%">&nbsp;</td><td width="92%"><a
href="http://www.mycompany.com" class="links">mycompany</a> | <a
href="http://www.mycompanyle.com/" class="links">Law Enforcement</a> | <a
href="http://www.mycompanymilitary.com/" class="links">Military</a> | <a
href="http://www.rempac.org/" class="links">REMPAC</a> | <a
href="http://www.mycompanypmpd.com/" class="links">PMPD</a> | <a
href="http://www.mycompany.com/login/customer_login?NEXTURL=/partner/def
ault%2Ehtm" class="links">Partner</a> | </td></tr></table>'
submenu[1]='<table width="100%" border="0" cellspacing="0"
cellpadding="0"><tr><td width="23%">&nbsp;</td><td width="77%"><a
href="default.aspx?P=1" class="links">Organizational</a> | <a
href="default.aspx?P=2" class="links">Historical</a> | <a href="#"
class="links"><a href="default.aspx?P=3" class="links">Link1</a> | <a
href="default.aspx?P=4" class="links">Link2</a> | <a
href="default.aspx?P=5"
class="links">Optics</a> | <a href="default.aspx?P=6"
class="links">Accessories</a> | <a href="default.aspx?P=8"
class="links">Hunting</a> | <a href="default.aspx?P=9"
class="links">Other</a> | <a href="default.aspx?P=10"
class="links">Sales</a></td></tr></table>'
submenu[2]='<table width="100%" border="0" cellspacing="0"
cellpadding="0"><tr><td width="61%">&nbsp;</td><td width="39%"><a href="#"
class="links">e-Signature Bill</a> | <a href="#" class="links">Digital
Document</a></td></tr></table>'
submenu[3]='<table width="100%" border="0" cellspacing="0"
cellpadding="0"><tr><td width="65%">&nbsp;</td><td width="35%"><a href="#"
class="links">News &amp; Events</a> | <a href="#" class="links">Policy
Alert</a> | <a href="#" class="links">Did You Know?</a></td></tr></table>'
//Set delay before submenu disappears after mouse moves out of it (in
milliseconds)
var delay_hide=300

/////No need to edit beyond here

var menuobj=document.getElementById? document.getElementById("describe") :
document.all? document.all.describe : document.layers?
document.dep1.document.dep2 : ""

function showit(which){
clear_delayhide()
thecontent=(which==-1)? "" : submenu[which]
if (document.getElementById||document.all)
menuobj.innerHTML=thecontent
else if (document.layers){
menuobj.document.write(thecontent)
menuobj.document.close()
}
}

function resetit(e){
if (document.all&&!menuobj.contains(e.toElement))
delayhide=setTimeout("showit(-1)",delay_hide)
else if (document.getElementById&&e.currentTarget!= e.relatedTarget&&
!contains_ns6(e.currentTarget, e.relatedTarget))
delayhide=setTimeout("showit(-1)",delay_hide)
}

function clear_delayhide(){
if (window.delayhide)
clearTimeout(delayhide)
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

</SCRIPT>
</td>
</tr>
<TR>
<TD height="18">
<table cellSpacing="0" cellPadding="0" width="770" align="center"
border="0">
<TR>
<TD>
<P>&nbsp;</P>
<P class="text" align="left">
<asp:Label id="Label2" runat="server" Width="694px"
CssClass="text">The quota system is a new part of the mycompany
managements
efforts to improve customer service. This system will provide the ability
to forecast at the sales class level. The tools provided include
forecasting at the customer level by inputting a percent improvement for
each of the business areas.</asp:Label></P>
<P class="text" align="center">
<asp:ListBox id="ListBox1" runat="server" Width="179px"
CssClass="text" DataTextField="name"
DataValueField="url" AutoPostBack="True"></asp:ListBox></P>
<P class="text" align="center"><asp:label id="Label1"
runat="server" Width="304px"></asp:label></P>
<P>&nbsp;</P>
<P>&nbsp;</P>
</TD>
</TR>
</table>
<table cellSpacing="0" cellPadding="0" width="770" align="center"
border="0">
<TR>
<TD>
<DIV align="center"><IMG height="2" src="images/hor_dot.gif"
width="652"></DIV>
</TD>
</TR>
<TR>
<TD height="6"></TD>
</TR>
<TR>
<TD bgColor="green" height="20">
<DIV class="botlinks" align="center"><A class="botlinks"
href="#"><U><FONT color="white">Home</FONT></U></A>
|&nbsp; <A class="botlinks" href="#"><U><FONT
color="white">FAQs</FONT></U></A>
| <A class="botlinks" href="#"><U><FONT color="white">Contact
Us</FONT></U></A></DIV>
</TD>
</TR>
<TR>
<TD height="20">
<DIV class="text" align="center">Copyright 2004. All rights
reserved mycompany Arms</DIV>
</TD>
</TR>
</table>
</TD>
</TR>
</table>
</form>
</body>
</HTML>


What I want to do is the following:

Where the graphics on our corporate website are rotated each month, I want
to construct the filename within this page in order to be able to put the
month & year and develop a link to the corporate website that'd pull the
appropriate graphic over to it, keeping our sales site in synch with the
corporate one.

I kinda know how to do this in VBscript, and have an old ASP page that I
have tested with and know that the code I developed in VBscript is good
and
does work like it should.

In my test, where I had the src=".... " statements on those graphics, I
was
able to pull in the graphics from the main website, after building the
filename and putting together the URL for the graphic. I had something
like
src="<%=filename1%>" and it worked.

However, this new page doesn't like the mixing of the VBscript with the
Javascript that's already on the page.

Is there a way for me to build the following in Javascript that'll work
within the page, and allow me to show those pictures and pull the new ones
as the month & year changes on the website.

testmonth = month(date)
testyear = year(date)
filenameyear = mid(testyear,3)
if testmonth < 10 then
testmonth = "0" & testmonth
end if

firearmsfname = "http://www.mycompany.com/images/splash/fi_" & testmonth &
filenameyear & ".jpg"
ammofname = "http://www.mycompany.com/images/splash/am_" & testmonth &
filenameyear & ".jpg"
accsfname = "http://www.mycompany.com/images/splash/ax_" & testmonth &
filenameyear & ".jpg"

I know the above works in ASP and in conjunction with the
src="<%=filename1%>" in the src part of the IMG tag. However, I know
nothing about Javascript or how to write it or make it execute the same
way
that the VBScript would.

How can I write the code above, put it into the html you see above that,
and
have both to work?

Any help/advice appreciated,

SC
 
M

Martin Dechev

Hi,

<snip>

Set the <img> to be runat="server":

<IMG height="100" id="img1" runat="server" width="200">
<IMG height="100" id="img2" runat="server" width="200">
<IMG height="100" id="img3" runat="server" width="200">

If you're using the code-behind model declare references to them in the page
class:

Protected img1, img2, img3 As System.Web.UI.HtmlControls.HtmlImage

And then simply format the DateTime instance representing the current date
in Page_Load handler when IsPostBack is False:

If Not(IsPostBack) Then
img1.Src =
String.Format("http://www.mywebsite.com/images/splash/fi_{0:MMyy}.jpg",
DateTime.Now)
img2.Src =
String.Format("http://www.mywebsite.com/images/splash/am_{0:MMyy}.jpg",
DateTime.Now)
img3.Src =
String.Format("http://www.mywebsite.com/images/splash/ax_{0:MMyy}.jpg",
DateTime.Now)
End If

You could, of course, set the src inline in the aspx page, but I don't like
the spaghetti code and I don't recommend it.

Have a look at the "Formatting Overview" topic in MSDN (in this particular
case we use custom DateTime format):
http://msdn.microsoft.com/library/en-us/cpguide/html/cpconformattingoverview.asp

Hope this helps
Martin
 

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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top