views:

50

answers:

2

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...

+1  A: 

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.

awe
Error 1The name 'MovingContent' does not exist in the current context E:\Hemaa\Form\welcome.aspxgot this error
Ayyappan.Anbalagan
I have just edited to fix the bugs. Try again. The last error I fixed was changing `ClientId => ClientID`. Now it should work (I have tested it now...)
awe
i am not getting anything in my page..after running the page.
Ayyappan.Anbalagan