ASP. NET announcement board DEMO code (C #)

Source: Internet
Author: User

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 ();
}
}
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.