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?
- <Div id = "demo" style = "overflow: hidden; width: 441px; border: 0px">
- <Table width = "441" height = "130" border = "0" cellpadding = "0" cellspacing = "0" background = "Images/img2/32.jpg">
- <Tr>
- <Td align = "center" id = "demo1" valign = "bottom">
- <Asp: DataList ID = "DataList1" runat = "server" RepeatDirection = "Horizontal" DataSourceID = "ObjectDataSource1">
- <ItemTemplate>
- <Table>
- <Tr>
- <Td>
- <Asp: ImageButton ID = "imgbtnInfo" runat = "server" ImageUrl = '<% # Eval ("Spic") %> 'onclick = "imgbtnInfo_Click"
- CommandArgument = '<% # Eval ("ID") %>'/>
- </Td>
- </Tr>
- <Tr>
- <Td align = "center">
- <Asp: LinkButton ID = "lkbtnInfo" CommandArgument = '<% # Eval ("ID") %> 'runat = "server"
- OnClick = "lkbtnInfo_Click" CssClass = "bb" Text = '<% # Eval ("Type") %>'> </asp: LinkButton>
- </Td>
- </Tr>
- </Table>
- </ItemTemplate>
- </Asp: DataList>
- <Asp: ObjectDataSource ID = "objectperformance1" runat = "server" SelectMethod = "SelectInfo"
- TypeName = "mongodal. KeFangServices"> </asp: ObjectDataSource>
- </Td>
- <% -- This step is important -- %>
- <Td id = "demo2" align = "center" valign = "bottom">
- </Td>
- </Tr>
- </Table>
- </Div>
- <Script>
- // Scroll speed. The greater the value, the slower the speed.
- Var speed = 20
- Demo2.innerHTML = demo1.innerHTML
- // From right to left
- Function Marquee (){
- If (demo1.offsetWidth-demo. scrollLeft <= 0)
- Demo. scrollLeft = 0
- Else
- Demo. scrollLeft ++
- }
- Var MyMar = setInterval (Marquee, speed)
- Demo. onmouseover = function () {clearInterval (MyMar )}
- Demo. onmouseout = function () {MyMar = setInterval (Marquee, speed )}
- </Script>