Simple ASP. NET 2.0 C # message book

Source: Internet
Author: User
Simple ASP. NET message Book Development Tool: vs2005
  1. Data logging Design

    • Create a data volume named webtest
      The SQL statement is as follows:
      Create Database webtest
    • Create a table named Databook
      The structure is as follows:

      Data Table Name ‑ Response Contains the delimiter
      Databook Accounting Basic Subject Assignment Region name Response Struct type Bytes size
      ID Bigint 8
      Topic Nvarchar 50
      Name Nvarchar 10
      Body Nvarchar 200
      IP Datetime 15

      The SQL statement is as follows:

      Create Table Databook (ID bigint identity (1, 1) Not for replication, subject varchar (50), name varchar (10), body varchar (200 ), IP varchar (15),) insert Databook select 'Broken content', 'Broken into reference', 'allowed internal content', '1970. 0.0.1 'Union all select 'random latest', 'Broken bytes latest', 'random bytes content', '100. 0.0.1'

  2. Leave a comment
    • Use the Response Message Interface Design
      Create a new guest. aspx file. The HTML generation is as follows:

      <% @ Page Language = "C #" autoeventwireup = "true" codefile = "guest. aspx. cs" inherits = "_ default" %> <! 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"> 

    • Leave a comment Program
      Using system; using system. data; using system. configuration; 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; public partial class _ default: system. web. UI. page {protected void page_load (Object sender, eventargs e) {If (! Ispostback) {binddata () ;}} public void binddata () {string connstr = configurationmanager. appsettings ["connectionstring"]. tostring (); sqlconnection sqlconn = new sqlconnection (connstr); string sqlstr = "select * From Databook"; sqldataadapter myadapter = new sqldataadapter (sqlstr, sqlconn ); dataset DS = new dataset (); myadapter. fill (DS, "Databook"); gridview1.datasource = Ds. tables ["Databook"]. defaultview; gridview1.databind ();} protected void button#click (Object sender, eventargs e) {sqlconnection Cn = new sqlconnection (configurationmanager. appsettings ["connectionstring"]. tostring (); CN. open (); string STR = "insert into Databook (subject, name, body, ip) values ('" + this. title. text. trim (). tostring () + "','" + this. name. text. trim (). tostring () + "','" + this. body. value. trim (). tostring () + "','" + request. userhostaddress. tostring () + "')"; sqlcommand COM = new sqlcommand (STR, CN); COM. executenonquery (); binddata ();}}
  3. View hosts
    • View Plane Design
      Create a new see. aspx file. The HTML generation is as follows:

      <% @ Page Language = "C #" autoeventwireup = "true" codefile = "see. aspx. CS "inherits =" see "%> <% @ import namespace =" system. data "%> <! 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"> 
    • View the program on behalf of zookeeper
      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; public partial class see: system. web. UI. page {protected void page_load (Object sender, eventargs e) {string thisid = request. querystring ["ID"]; string connstr = configurationmanager. appsettings ["connectionstring"]. tostring (); sqlconnection sqlconn = new sqlconnection (connstr); string sqlstr = "select * From Databook where id =" + thisid + ""; sqldataadapter myadapter = new sqldataadapter (sqlstr, sqlconn); dataset DS = new dataset (); myadapter. fill (DS, "Databook"); datalist1.datasource = Ds. tables ["Databook"]. defaultview; datalist1.databind ();}}
  4. Web. config file replacement
    <? XML version = "1.0"?> <! -- Note: In addition to manual debugging, you can also use web management tools to set the value of your application. Select [website]> [ASP. NET Organization] in Visual Studio. If you need to complete the configuration and clarification form, please test the machine. config. comments (usually in \ windows \ Microsoft. net \ framework \ v2.x \ config) --> <configuration> <etettings> <add key = "connectionstring" value = "Server = 210.1.1.22; database = webtest; uid = sa; pwd =; "/> </appsettings> <connectionstrings/> <system. web> <! -- If compilation DEBUG = "true" is set, the operator is inserted into the hidden plane. Because this affects the performance, this value can be set to true only during the development period. --> <Compilation DEBUG = "true"/> <! -- <Authentication> zones can be used to set the Security Authentication mode used by ASP. NET to identify users who access the region. --> <Authentication mode = "Windows"/> <! -- <Customerrors> the region can be used to set the action to be performed when the bank fails to handle the operation within the required period. In practice, it allows developers to set the HTML webpage to be displayed to replace the hacker heap tracing. <Customerrors mode = "remoteonly" defaultredirect = "genericerrorpage.htm"> <error statuscode = "403" Redirect = "noaccess.htm"/> <error statuscode = "404" Redirect = "deny "/> </customerrors> --> </system. web> </configuration>
Under the source region

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.