ASP. NET Study Notes 1

Source: Internet
Author: User

1. pagination of the DataGrid
In addition to settings:

AllowPaging is used to allow paging, which is the most important. With it, we can paging.

PageSize indicates the number of records displayed on each page. If not written, 10 records are displayed by default.

In addition, add:

OnPageIndexChanged = "Maid pageindexchanged"

Public void datagrid#pageindexchanged (object sender, DataGridPageChangedEventArgs e)

{

DataGrid1.CurrentPageIndex = e. NewPageIndex;

DataGrid1.DataBind ();

}

Ii. about uploading files
To upload files, add:

<Form id = "Form1" enctype = "multipart/form-data" method = "post" runat = "server">

Add the following content to the source file:

If (File1.PostedFile! = Null)

{

File1.PostedFile. SaveAs (Server. MapPath ("\ 1.jpg "));

Image1.ImageUrl = Server. MapPath ("\ 1.jpg ");

}

Iii. Automatic refresh
HTML should be added:

<Meta http-equiv = "REFRESH" content = "10; URL = chat. aspx">

Automatic window ScrollWindow ():

<Script language = javascript 1.1>

Function scrollWindow ()

{

This. scroll (0,65000 );

SetTimeout ('rollwindow () ', 200 );

}

ScrollWindow ();

</Script>

4. Connect to the SQL database
String _ SQL;

SqlConnection cn;

_ SQL = "server = localhost; uid = sa; pwd = hz0222; database = Northwind ";

Cn = new SqlConnection (_ SQL );

Cn. Open ();

// SqlCommand cmd = new SqlCommand ("select * from Products", cn );

// SqlDataReader rs;

// Rs = cmd. ExecuteReader ();

SqlDataAdapter da = new SqlDataAdapter ("select * from Products", cn );

DataSet ds = new DataSet ();

Da. Fill (ds, "Products ");

DataGrid1.DataSource = ds. Tables ["Products"]. DefaultView;

// DataGrid1.CurrentPageIndex = 0;

DataGrid1.DataBind ();

Cn. Close ();

5. Query IP addresses
Private void Button6_Click (object sender, System. EventArgs e)

{

IPHostEntry hostInfo = Dns. GetHostByName (txtDomain. Text );

Response. Write ("<br>" + hostInfo. AddressList [0]. ToString ());

}

Remember to use the cited namespace System. Net

6. Load processing pages in HTML
<Form method = "post" action = "index2.aspx">

7. Use the TreeView Control
A) download and install IEWebControls: http://www.asp.net/IEWebControls/Download.aspx

B) after installation, a directory will be created by default: \ Program files \ IEWeb Controls \. Of course, you can change the installation directory. Find the Directory and double-click build. execute the bat file. It will create a subdirectory named build and compile the source file under the src directory, copy the compilation result and Runtime directory to the build subdirectory (automatically ). After this action, there should be a file named "Microsoft. Web. UI. WebControls. dll" and a Runtime subdirectory under the build directory. In order. NET Web applications, you must copy the content in the \ build \ Runtime sub-directory to the/webctrl_client/Runtime 0 sub-directory of the Web application, and put "Microsoft. web. UI. webControls. dll "is copied to the/bin directory of the Web application. This process is described in detail in the readme.txt file, but in English.

C) then, you can add a tool in Toolbox (this should not be clear)

D) The following is the instructions for WebControls (E)

To run the IE Web Controls:

1. Copy the contents of the Runtime directory to the webctrl_client \ defaults 0

Directory under your top-level site directory. For example, if your

Site root is c: \ Inetpub \ wwwroot, type this at the command prompt:

Xcopy/s/I. \ build \ Runtime c: \ Inetpub \ wwwroot \ webctrl_client \ defaults 0/y

This will create the following directory structure under the site:

/Webctrl_client/route 0

MultiPage. htc

TabStrip. htc

Toolbar. htc

Treeview. htc

Webservice. htc

Webserviced. htc

[Images]

[Treeimages]

2. Create a new web application in IIS and copy the contents of

Samples directory to this application directory. For example:

Xcopy/s/I. \ samples c: \ Inetpub \ wwwroot \ sampleapp/y

3. Create a/bin subdirectory for the application and copy the file

Microsoft. Web. UI. WebControls. dll to this directory.

The contents of the application will be as follows:

/Sampleapp

Multipage. aspx

State_city.xml

Tabstrip. aspx

Toolbar. aspx

Treeview. aspx

Treeview_bound.aspx

/Bin

Microsoft. Web. UI. WebControls. dll

4. Request the sample pages from your Internet Explorer web browser,

Example: http: // localhost/sampleapp/multipage. aspx

8. Cancel IE content security verification
A) validateRequest = "false"

9. Third-party Dtable control usage
A) Make sure that the <form ...... Remove

B) The first field of the connected table must be of the int type Automatically numbered. It is best to add the ASP. NET account for SQL verification.

C) For other questions, please refer to the Forum http://dtable.2smm.com

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.