Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Implement Moving content/text in website. in asp.net

How to Implement Moving content/text in website like a marquee. In asp.net.

I have values in my data set.the data set value must be displayed in div like a rotating flash news...

like image 921
Ayyappan Anbalagan Avatar asked May 12 '10 11:05

Ayyappan Anbalagan


1 Answers

Simple example to slide a div over the page:

<asp:Panel id="MovingContent" runat="server"
     style="position:absolute;left:-100px;top:20px;height:40px;width:100px;">
The content that will move
</asp:Panel>

<script type="text/javascript">

//Initial position 
//(should be the same as the position specified in the element's style)
posX = -100;
posY = 20;

//Position where the element will stop
targetX=200;
targetY=60;

function move(){
 if(posX < targetX){
  posX += 10;
  if(posY < targetY) posY += 1;
  var divElement = document.getElementById('<%=MovingContent.ClientID%>');
  divElement.style.left = posX + 'px';
  divElement.style.top = posY + 'px';

  //Time in milliseconds to when to move next step
  self.setTimeout('move()', 100); 

 }
}

move(); //Start the moving

</script>

You might improve it to your needs, but this can be used as a basic idea how to do it.

like image 66
awe Avatar answered Nov 15 '22 01:11

awe