Code record 1 in the News Publishing System

Source: Internet
Author: User

1. method call for the start page on Layer 3

Response. Write (sqlhelper. Test (); // static method call response. Write (New sqlhelper (). Test (); // non-static method call

2. Press the tab key twice in a row to automatically display it.CodeExample:

After writing the switch, press the tab key twice in a row. The code and format will be automatically generated (in)

3. Simpler Method for closing a connection (the try-catch method can be replaced)

Using (SDR = cmd. executereader (commandbehavior. closeconnection) {DT. Load (SDR );}

Try-catch is written as follows:

 
Public int executenonquery (string plain text, commandtype CT) {int res; try {cmd = new sqlcommand (plain text, getconn (); cmd. commandtype = CT; Res = cmd. executenonquery ();} catch (exception ex) {Throw ex;} finally {If (Conn. state = connectionstate. open) {Conn. close () ;}} return res ;}

The simple method described above is as follows:

Public datatable executequery (string plain text, commandtype CT) {datatable dt = new datatable (); cmd = new sqlcommand (plain text, getconn (); cmd. commandtype = CT; using (SDR = cmd. executereader (commandbehavior. closeconnection) {DT. load (SDR) ;}return DT ;}

4. Tips: add comments. Using region to add comments is easier to hide.

# Add ten popular news articles to region /// <summary> /// retrieve the top 10 news articles (category, news title, and release time) /// </Summary> /// <returns> </returns> Public datatable selectnewnews () {return sqlhelper. test ("procnewsselectnewnews");} # endregion

5. An attribute that keeps the position of the scroll bar unchanged

 maintainscrollpositiononpostback = "true" 

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.