This is thủ dựng kha simple but with you the new settings can be the problem kho. And here command prompt main also be in the Community hmweb đàn. Write to me nghi direction path sure you will be easy apply for you with than. Trọng html with tag Marquee can help ta execute effect you văn scroll. You can tham khao post Some tag HTML special for than to the tag special and the property of the tag Marquee. Nhắm post to this simple me how to use and truy vấn next DataReaders use directly to display data (You can tham khao post SqlDataReader và tập hợp dữ liệu than to understand about DataReaders). Assuming you with the table TB_News field Basic as NewID, Tiêu đề, mô tả, ... when it ta after write function to display data with 10 log latest scroll effect with text and when user to the mouse di data this does it will stop the, di mouse ra data from the next data it will anyway scroll. Hàm as is write after:
private string GetTopNews() { string strHTML = ""; strHTML += "<marquee width=\"280px\" height=200 "; strHTML += "style=\"border:1px solid #dddddd; padding:5px; text-align:justify; line-height:20px\" "; strHTML += "onmouseover=\"this.stop()\" onmouseout=\"this.start()\" scrollamount=\"2\" scrolldelay=\"1\" "; strHTML += "direction=\"up\" loop=\"infinite\">"; // Khai báo chuỗi kết nối string connectString = @"Server =.\SQL2005;Initial Catalog=DB_News;User ID=sa;Password=****"; // Khai báo câu truy vấn string sql = @"SELECT TOP 10 NewID, Title FROM TB_News ORDER BY NewID desc"; // Tạo một connection tới máy chủ SqlConnection conn = new SqlConnection(connectString); try { conn.Open(); SqlCommand cmd = new SqlCommand(sql, conn); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { strHTML += "» <a href='?newsid=" + reader[0] + "'>" + reader[1] + "</a><br>"; } reader.Close();//Đóng SqlDataReader } catch (SqlException ex) { Console.WriteLine("Error: " + ex); } finally { conn.Close(); } strHTML += "</marquee>"; return strHTML; }In your aspx code as illustrated by the following:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Marrquee_News.aspx.cs" Inherits="Marrquee_News" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <style> a{color:#333333; text-decoration:none;} a:hover{color:Maroon; text-decoration: underline;} </style> <title>hmweb Dùng Thẻ Marquee Scoll các bài viết mới</title> </head> <body> <form id="form1" runat="server"> <div style="border:0px; width:282px; padding:5px; text-align:justify; height:28px; line-height:28px; background-color:#006699; color:#FFFFFF"> <center>Mới cập nhật</center> <br /> </div> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> </form> </body> </html>Display:
protected void Page_Load(object sender, EventArgs e) { Label1.Text= GetTopNews(); }
Không có nhận xét nào:
Đăng nhận xét