Use DataList in ASP. NET to implement seamless image scrolling,

Source: Internet
Author: User

Use DataList in ASP. NET to implement seamless image scrolling,

This problem has also plagued me before. I solved it later and shared it with me. It will be convenient to use it later, and the code will be easy to understand. I will not talk much about it.

[Html]View plaincopyprint?
  1. <Div id = "demo" style = "overflow: hidden; width: 441px; border: 0px">
  2. <Table width = "441" height = "130" border = "0" cellpadding = "0" cellspacing = "0" background = "Images/img2/32.jpg">
  3. <Tr>
  4. <Td align = "center" id = "demo1" valign = "bottom">
  5. <Asp: DataList ID = "DataList1" runat = "server" RepeatDirection = "Horizontal" DataSourceID = "ObjectDataSource1">
  6. <ItemTemplate>
  7. <Table>
  8. <Tr>
  9. <Td>
  10. <Asp: ImageButton ID = "imgbtnInfo" runat = "server" ImageUrl = '<% # Eval ("Spic") %> 'onclick = "imgbtnInfo_Click"
  11. CommandArgument = '<% # Eval ("ID") %>'/>
  12. </Td>
  13. </Tr>
  14. <Tr>
  15. <Td align = "center">
  16. <Asp: LinkButton ID = "lkbtnInfo" CommandArgument = '<% # Eval ("ID") %> 'runat = "server"
  17. OnClick = "lkbtnInfo_Click" CssClass = "bb" Text = '<% # Eval ("Type") %>'> </asp: LinkButton>
  18. </Td>
  19. </Tr>
  20. </Table>
  21. </ItemTemplate>
  22. </Asp: DataList>
  23. <Asp: ObjectDataSource ID = "objectperformance1" runat = "server" SelectMethod = "SelectInfo"
  24. TypeName = "mongodal. KeFangServices"> </asp: ObjectDataSource>
  25. </Td>
  26. <% -- This step is important -- %>
  27. <Td id = "demo2" align = "center" valign = "bottom">
  28. </Td>
  29. </Tr>
  30. </Table>
  31. </Div>
  32. <Script>
  33. // Scroll speed. The greater the value, the slower the speed.
  34. Var speed = 20
  35. Demo2.innerHTML = demo1.innerHTML
  36. // From right to left
  37. Function Marquee (){
  38. If (demo1.offsetWidth-demo. scrollLeft <= 0)
  39. Demo. scrollLeft = 0
  40. Else
  41. Demo. scrollLeft ++
  42. }
  43. Var MyMar = setInterval (Marquee, speed)
  44. Demo. onmouseover = function () {clearInterval (MyMar )}
  45. Demo. onmouseout = function () {MyMar = setInterval (Marquee, speed )}
  46. </Script>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.