The first is the front-end code, mainly the use of the marquee mark, and how to implement the communication between JS and Asp.net background variables. This technology extends the use of ASP
The style of the times.
<% @ Page Language = "C #" autoeventwireup = "true" codefile = "default3.aspx. cs" inherits = "default3" %>
<! 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">
<Title> announcement panel demo </title>
</Head>
<Body>
<Form ID = "form1" runat = "server">
<Div>
<Marquee behavior = scroll ction = left Height = 76 scrollamount = 1 scrolldelay = 60 onmouseover = 'this. Stop () 'onmouseout = 'this. Start () '>
<SCRIPT>
VaR showmsg1 = "<% = showmsg %>"
Document. Write (showmsg1 );
</SCRIPT>
</Marquee
></Div>
</Form>
</Body>
</Html>
The following is the background code to retrieve the announcement content from the database:
Using system;
Using system. Data;
Using system. configuration;
Using system. collections;
Using system. Web;
Using system. Web. Security;
Using system. Web. UI;
Using system. Web. UI. webcontrols;
Using system. Web. UI. webcontrols. webparts;
Using system. Web. UI. htmlcontrols;
Using system. Data. sqlclient;
/**//*
DEMO code of ASP. NET announcement board
* Coder linqifo * Time: 2007-11-1
*/
Public partial class default3: system. Web. UI. Page
...{
Public int noticenum = 1;
// Ensure that the access level is protected or above.
Public String showmsg = string. Empty; // store the announcement to be displayed.
Protected void page_load (Object sender, eventargs E)
...{
String plain text = "select * from notice ";
// The following code retrieves content from the database:
Sqlconnection conn = new sqlconnection (system. configuration. configurationmanager. connectionstrings ["justseeoaconnectionstring"]. connectionstring );
Sqlcommand cmd = new sqlcommand (plain text, Conn );
Conn. open ();
Sqldatareader DR = cmd. executereader ();
While (dr. Read ())
...{
Showmsg + = noticenum. tostring () + ":" + Dr ["noticedate"]. tostring () + ":" +
Dr ["noticecontent"]. tostring () + Dr ["fullname"]. tostring () + "";
Noticenum ++;
}
Noticenum --;
Conn. Close ();
}
}