using java script on the asp web form

Posted by mpiloadvocate-2219 under ASP.NET on 4/28/2011 | Points: 10 | Views : 1282 | Status : [Member] | Replies : 1
hi have coded on the source side of the asp page..this code surpose to make pictures swope from 3 table data</td> it working on the html file but not on the asp source side...i could add the </html>,</head> tags on it..

<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="iMusic.aspx.vb" Inherits="iKlikit.WebForm1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
<style type="text/css">
width: 100%;
width: 885px;
width: 218px;

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

<script language="javascript">

function rotate()
var s = document.images[2].src;
for (k = 2; k > 0; k--)
document.images[k].src = document.images[k - 1].src;
document.images[0].src = s;

function start() {
var v = setInterval("rotate()", 2000)
<body onload="start()">
the picture array i did it on the body....the pictures do apear bt not swoping


Posted by: Ndebata on: 4/28/2011 [Member] Starter | Points: 25


As you are using master page and image you are trying to rotate is on child page, the start() method should be called in the onload of masterpage body, there should not be any body in the child page.
So in the body tag of master page set runat="server" and id="_mbody".
Then expose a public property in the MasterPage which will return _mbody;

In the child page aspx page add a refernece to Master
put the all the script to headercontent section
then on page intialization of child page
add onload attribute of masterbody property which you have exposed.

Take a look at the attached sample Master Page and relavant child page.
 Download source file

mpiloadvocate-2219, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response