An extract of the details of ASP.

Source: Internet
Author: User
Tags tagname xsl xsl file

The difference between 1.<%=...%> and <%# ...%>: A:<%=...%> is called when the program executes, <%# ...
%> is called after the DataBind () method
2. What types of data does the control receive?
A: The control that receives the bind, generally has the control which dropdownlist,datalist,datagrid,listbox these collection nature, but is bound
The main tie is ArrayList (array), Hashtable (table), DataView (Data View), DataReader These four, we can
In the seat, there will be no DataTable bundled error:)
3.DataBind, the data obtained, the system will be implicitly think of the string, how to convert to other types?
DataBinder.Eval (Container.DataItem, "type of conversion", "format")
The last "format" is optional and generally does not need to be used, Container.DataItem is a bundle of data items, "conversion type" refers to the
Integer,string,boolean this kind of thing.
4. Primary namespaces:
<% @ Import
Namespace= "System.Data"%> when processing data
<% @ Import
Namespace= "System.Data.ADO"% > Use ADO; When used to
<% @ Import
Namespace= "System.Data.SQL"%> SQL Server Database Private
<% @ Import
Namespace= "System.Data.xml"%> without looking at the processing XML used to
<% @ Import
Namespace= "System.IO"%> when working with files
<% @ Import
Namespace= "System.Web.Util"%> email when you use
<% @ Import
Namespace= "System.Text"%> text encoding
5.Connections (Sqlconection or
ADOConnection) Common Properties and methods:
| ConnectionString Gets or sets the statement of the linked database
|
ConnectionTimeout Gets or sets the maximum time to connect to the database, and it is the time-out
| DataBase
Gets or sets the name of the database to open on the database server
| DataSource Get or Set DSN, everyone will not be unfamiliar with it:)
| PassWord
Get or set a password
| UserID Gets or sets the login name
| State to get the status of the current junction
| Open () opens the junction
|
Close () closes the junction
| Clone ()
Clones a junction. (Oh, sheep can connection I can)
Example:
SQLConnection myconnection = new
SQLConnection ();
Myconnection.datasource =
"MySQLServer";
Myconnection.password = "";
Myconnection.userid =
"SA";
Myconnection.connectiontimeout =
30;
Myconnection.open ();
Myconnection.database =
"Northwind";
Myconnection.isolationlevel =
isolationlevel.readcommitted
6.Command Common methods and properties
| ActiveConnection
Gets or sets the junction connections
| SQL statement or stored procedure (storedprocedure) name executed by CommandText
|
CommandTimeout the maximum time to execute
| CommandType
Type of command operation (storedprocedure,text,tabledirect) three, default Text
| Parameters
Use when operating the stored procedure
| Execute () executes an SQL statement or stored procedure
| ExecuteNonQuery ()
As above, the difference is not to return the recordset
| Clone () Cloning command
Example:
String myselectquery =
"SELECT * from Categories ORDER by
CategoryID ";
stringmyconnectstring= "userid=sa;password=;d atabase=northwind;server=mysqlserver";
SQLCommand
mycommand = new SQLCommand (mySelectQuery);
Mycommand.activeconnection = new
SQLConnection (myconnectstring);
Mycommand.commandtimeout =
15;
myCommand.CommandType = commandtype.text;</font
>
7. Open and close the database in two ways:
1.myconnection.open ();
Open Junction
Myconnection.close ();
2.mycommand.activeconnection.open ();
MyCommand.ActiveConnection.Close ()
8. Use a dataset to add, modify, and delete a data in the database
A. Adding data
DataRow
dr=mydataset.tables["UserList"]. NewRow ();
dr["UserName"] =
"Zhou Xun";
dr["ReMark"] = "100";
dr["Comment"] =
"Beautiful mm";
MYDATASET.TABLES.ROWS.ADD (DR);
B. Modifying data
mydataset.tables["UserList"]. rows[0]["UserName"]= "flying brother";
C. Deleting data
mydataset.tables["UserList"],rows[0]. Delete ();
D. Recovering data
if (mydataset.haserrors)
{
Mydataset.rejectchanges ();
}
E. Detecting if the dataset has changed
if (mydataset.haschanges)
{
Save Code
}else{
Because there is no change, so do not save, to save time
}
F. Updating the database
Mycomm.update (myDataSet);
Update all tables in the database
Mycomm.update (myDataSet, "userlist");
Update a table
9.DataGrid for paging functionality
Allowpaging= "True"
is to allow paging, this is the most important. With it, we can split pages.
Pagesize= "5"
is to specify the number of records to display per page, and default to 10 if not written.
Pagerstyle-horizontalalign= "Right"
Is the positioning of the specified facet display, which is left by default
pagerstyle-nextpagetext= "Next Page"
Change <> to previous page and next page string
pagerstyle-prevpagetext= "Previous Page"
Pagerstyle-mode= "NumericPages"
Change <> to 123 digital display
10. Displays the total number of pages, and the report is currently the first page
The current page is: <font
Color=red><%=datagrid1.currentpageindex+1%></font><br>
Total pages are: <font
Color=red><%=datagrid1.pagecount%></font><br>
11. Personalized Paging
The "close contact with ASP. NET (14)" In the programmer's stronghold has complete code
12. To reset the page to a valid state
IValidator
Val
foreach (Val in validators)
{
Val.isvalid =
True
}
13. Re-execute the entire validation sequence
IValidator Val;
foreach (Val in
validators)
{
Val.validate ();
}

14. Disable client-side validation <%@ page language= "C #" Clienttarget=downlevel
%>
15.Repeater, DataList, and DataGrid control uses "
These controls can simplify several common Web
Application scenarios, including reports, shopping carts, product listings, query results, and navigation menus. Repeater is the only one that is allowed to exist in its template
The control for the HTML fragment.
16.server.execute ("another.aspx") and Server.Transfer ("another.aspx") differ: Execute is transferred from the current page to the specified page, and returns the execution to the current page transfer is to perform a full transfer to the specified page
The 17.XML file can either own the schema or exist in the *.xsl file, but it must be specified in the root node of the XML document through the xmlns attribute, as follows:
<rootelement
xmlns= "X-schema:scheduledschema.xsl" >
Reading of 18.XML files
FileStream
Myfs=new
Filestream (Server.MapPath ("Xmldtagrid.xml"), FileMode.Open,FileAccess.Read);
StreamReader
Myreader=new StreamReader (MYFS);
DataSet myds=new
DataSet ();
myDS. READXML (myreader);
19. Regular Expressions
Control RegularExpressionValidator
Symbolic meaning
^ Specify the beginning of the check
$
Specify where to end the check
[] Checks whether the input value matches one of the characters in square brackets
\w allows you to enter any value
\d{}
"\d" specifies that the value entered is a number, {} Indicates the number of occurrences of the specified data type
+
Indicates that one or more elements will be added to the expression being checked
Example: e-mail format with an @ sign and a. Com/.net/.org/.edu end)
Validationexpression= "^[\w-][email protected][\w-]+\. (com|net|org|edu) $"
Important statements for data manipulation in 20.DataGrid controls:
Property: datakeyfield= "userid"
Set the UserID as the primary key of the table, cannot update the value of the field to the database, preferably set the primary key of the table as the primary key of the DataGrid
sqlcommand.parameters["@userid"]. VALUE=DG. datakeys[(int) e. Item.itemindex];
Retrieves the primary key of the row to be updated (the current selected row's
The number of one parameter assigned to the command by the primary key value
sqlcommand.parameters["@fname"]. Value= (TextBox) e.item.cells[2]. Controls[0]). Text;
Assigning a modified row value to a parameter
21. Custom CONTROLS:
A. User control (ASP create page)
(I).
Create a page, drag into the control, set properties/methods. <% @Control language= "C #" debug= "True"
The @control directive in%> to define this page will contain the control code
(II)
Save as a *.ascx file, such as A.ascx.
(III). Use: Head <% @Register tagprefix= "Myfirstcontrol"
Tagname= "Mylbl" src= "A.axcs"
%>
TagPrefix is the prefix for the control, like ASP in Asp:textbox
TagName used to specify the name of the custom control
SRC Specifies the control file source
Body: &LT;MYFIRSTCONTROL:MYLBL
runat= "Server" id= "Allmine" mytext= "succeeded"/>
B. Creating a custom control using C #
(I).
Create a pure code file, inherit the base class control, and save it as *.cs, such as A.cs.
(II). Compiling code to build the assembly: csc/t:library
/r:system.dll,system.web.dll A.cs
The library tells the C # compiler to build the assembly
//
/r:system.dll
System.Web.Dll tells the C # compiler to reference the specified assembly
(III). Place the build DLL file in the bin directory
(IV). Use: <%
@Register tagprefix= "Mine" namespace= "Myowncontrols" assembly= "a"
%>
22. Composite Control Considerations:
public class
Mycompositin:control,inamingcontainer
INamingContainer: If there are multiple instances of this control on the page, this node can give each {}
Each instance has a unique flag
This. EnsureChildControls ();//indicates that the child controls of the composite control are rendered to the page, and this method checks whether the server control contains child controls
CreateChildControls
When does 23.button/linkbutton/imagebutton/hyperlink use?
1.Button and ImageButton are used to pass data back to the server.
2.Hyperlink for navigating between pages
3.LinkButton data that is used to save data to the server or access the server
24. Track and Debug
Tracking:
1. Page-level tracking:
At the beginning of the page include the following Page directive <%@ page trace= "True" tracemode= "Sortbycategory/sortbytime"
%>
Custom message:
Trace.Write ("Here is the string to be displayed");
Trace.Warn ("Here is the string to be displayed");
Same as Trace.Write, except that the font is red
Check if traces are used
Example: if (trace.isenabled) {
Trace.Warn ("Tracing Enabled")}
2. Application-level tracking: In the <System.Web> section of the Web. config file
<trace enabled= "true"
Pageoutput= "true"/>
25. Set the cache:
1. Output cache:
I. Page Setup: Will <%@
OutputCache duration= "" varybyparam= "None"%>
Add at the beginning of the page you want to cache
Note: The output content is unchanged within two minutes of requesting the page
II. Programming Mode settings:
The main use of the method under the class System.Web.HttpCachePolicy class
(1).
Response.Cache.SetExpires (DateTime.Now.AddSeconds (120));//The expiration time must be specified in this method, such as this
Language
Sentence is two minutes
(2).
Response.Cache.SetExpires (DateTime.Now.AddSeconds (120));
Response.Cache.SetSlidingExpiration (TRUE);
"Adjustable expiration", which is used primarily for those who start a large amount of access, but then access
The situation of volume balance
Function: The first sentence sets the cache expiration time, the second line opens sliding
Expiration (adjustable expiration).
2. Data caching:
(1). DataView MySource;
(2). assigning values to MySource;
(3). cache["Mycache"]=mysource;
(4). Mysource= (DataView) cache["Mycache"]
26. Deploy: Copy statements directly to the product server: XCOPY
<source_path> <destination_path>//xopy accepts only physical paths and does not accept virtual paths

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.