ASP. NET skills (Personal organization)

Source: Internet
Author: User
Tags tagname xsl xsl file

I hope to help you collect collected materials online. 1. Differences between <% =... %> and <% #... %>:A: <% =... %> is called when the program is executed. <% #... %> is called after the databind () method.2. What types of data does the control receive?A: controls that receive the BIND include dropdownlist ,{
Function onclick ()
{
Tagshow (Event)
}
} "> Datalist, DataGrid, ListBox, and these set-based controls are bundled mainly with arraylist (array), hashtable (HA table), and dataview (data view ), the four datareader items can be seated in the future, without the able bundling error :) 51 {
Function onclick ()
{
Tagshow (Event)
}
} "> Aspx.com3. databind, obtained data ,{
Function onclick ()
{
Tagshow (Event)
}
} "> The system will default it to string. How can it be converted to another type?
Databinder. eval (container. dataitem, "converted type", "format") the last "format" is optional. Generally, you do not need to worry about it, container. dataitem is a bundled data item. "Conversion Type" refers to integer, string, and Boolean.4. Main name {
Function onclick ()
{
Tagshow (Event)
}
} "> Space:
<% @ Import namespace = "system. data "%> used for data processing <% @ import namespace =" system. data. <% @ import namespace = "system. data. SQL "%> SQL Server {
Function onclick ()
{
Tagshow (Event)
}
} "> Dedicated database <% @ import namespace =" system. data. XML "%> not used to process XML <% @ import namespace =" system. io "%> used for file processing <% @ import namespace =" system. web. util "%> used when sending an email <% @ import namespace =" system. text "%> used for Text Encoding5. common attributes and methods of connections (sqlconection or adoconnection:| Connectionstring gets or sets the statement for connecting to the database | connectiontimeout gets or sets the maximum time for connecting to the database, which is also the timeout time | the database is obtained or set in the database {
Function onclick ()
{
Tagshow (Event)
}
} "> Name of the database to be opened on the server | datasource gets or sets the DSN, no stranger to everyone :) | password acquisition or password setting | userid acquisition or login name setting | state acquisition current connection status | open () open link | close () close join | clone () to clone a join. (Haha, you can connect me or sheep) Example: sqlconnection myconnection = new sqlconnection (); myconnection. datasource = "mysqlserver"; myconnection. password = ""; myconnection. userid = "sa"; myconnection. connectiontimeout = 30; myconnection. open (); myconnection. database = "northwind"; myconnection. isolationlevel = isolationlevel. readcommitted6. common methods and attributes of command| Activeconnection obtains or sets the connection Connections | Name of the SQL statement or stored procedure (storedprocedure) executed by commandtext | maximum commandtimeout execution time | commandtype command operation type (storedprocedure, text, tabledirect) three types, default: Text | used when parameters is used to operate a stored procedure | execute () executes an SQL statement or stored procedure | executenonquery () is the same as above, but does not return a record set | clone () clone command example: String myselectquery = "select * from categories order by categoryid"; stringyy; sqlcommand mycommand = new sqlcommand (myselectquery); mycommand. activeconnection = new sqlconnection (myconnectstring); mycommand. commandtimeout = 15; mycommand. commandtype = commandtype. text; </font>7. You can open or close a database in either of the following ways:1. myconnection. open (); // open the connection myconnection. Close (); 2. mycommand. activeconnection. open (); mycommand. activeconnection. Close ()8. Use dataset to add, modify, and delete data in the database.A. add data

  1. Datarow DR = mydataset. Tables ["userlist"]. newrow ();
  2. Dr ["username"] = "Zhou Xun ";
  3. Dr ["remark"] = "100 ";
  4. Dr ["comment"] = "Beautiful mm ";
  5. Mydataset. Tables. Rows. Add (DR );

Copy code

B. modify the data mydataset. tables ["userlist"]. rows [0] ["username"] = "Flying knife"; C. delete data mydataset. tables ["userlist"], rows [0]. delete (); D. restore data if (mydataset. haserrors) {mydataset. rejectchanges ();} e. test whether dataset has changed if (mydataset. haschanges) {// Save the code} else {// because there is no change, you do not need to save the time} f. update the database mycomm. update (mydataset); // update all tables in the database mycomm. update (mydataset, "userlist"); // update a table9. The DataGrid provides the paging function.

  1. Allowpaging = "true" // indicates that pagination is allowed. With it, we can paging.
  2. Pagesize = "5" // specifies the number of records displayed on each page. If this parameter is not set, 10 records are displayed by default.
  3. Pagerstyle-horizontalalign = "right" // specifies the position of the split display. The default value is left.
  4. Pagerstyle-nextpagetext = "next page" // change <> to the string of the previous page and next page.
  5. Pagerstyle-prevpagetext = "Previous Page"
  6. Pagerstyle-mode = "numericpages" // change <> to 123 Numeric Display

Copy code

10. display the total number of pages and the current report is the page numberThe current page is: <font color = Red> <% = datagrid1.currentpageindex + 1%> </font> <br> the total number of pages is: <font color = Red> <% = datagrid1.pagecount %> </font> <br>11. Personalized Paging{
Function onclick ()
{
Tagshow (Event)
}
} "> Programmer base camp" close contact with ASP. NET (14) "has complete code12. set {
Function onclick ()
{
Tagshow (Event)
}
} "> The page is reset to a valid status.
Ivalidator val; foreach (Val in validators) {Val. isvalid = true; // bbs.51aspx.com}13. Re-execute the entire verification sequenceIvalidator val; foreach (Val in validators) {Val. Validate ();}14. disable Client Verification<% @ Page Language = "C #" clienttarget = downlevel %>15. repeater, datalist, and DataGrid Control usage"These controls simplify several common web application solutions, including reports, shopping carts, product lists, query results, and navigation menus. Repeater is the only control that allows HTML fragments to exist in its template.16. Differences between server. Execute ("another. aspx") and server. Transfer ("another. aspx:Execute transfers the execution from the current page to the specified page, and returns the execution to the current page. Transfer completely transfers the execution to the specified page.17. The XML file can either have its own architecture or exist in the *. XSL file, but the information must be specified in the root node of the XML file through the xmlns attribute, as shown below:<Rootelement xmlns = "X-schema: scheduledschema. XSL">18. Reading XML files

  1. Filestream myfs = new filestream (server. mappath ("xmldtagrid. xml"), filemode. Open, fileaccess. Read );
  2. Streamreader myreader = new streamreader (myfs );
  3. Dataset myds = new dataset ();
  4. Myds. readxml (myreader );

Copy code

19. regularexpressionvalidatorSymbol Meaning ^ specify Check Start position $ specify check End [] Check whether the input value matches one of the characters in square brackets/W allow entering any value/d {} "/d "The input value 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: email format (with @ number and. COM /. net /. org /. end of EDU) validati20. Important statements for data operations in the DataGrid Control:Attribute atakeyfield = "userid" // set userid as the primary key of the table. The value of this field cannot be updated to the database. It is best to set the primary key of the table as the primary key of the DataGrid {
Function onclick ()
{
Tagshow (Event)
}
} "> Sqlcommand. parameters ["@ userid"]. value = DG. datakeys [(INT) E. item. itemindex]; // retrieves the primary key of the row to be updated (assign the primary key value of the currently selected row to a parameter of the command) sqlcommand. parameters ["@ fname"]. value = (textbox) E. item. cells [2]. controls [0]). text; // assign the modified row value to the parameter21. Custom Controls:A. User Control (the same as ASP creation page) (I). Create a page, drag the control, and set properties/methods. <% @ Control Language = "{
Function onclick ()
{
Tagshow (Event)
}
} "> C #" DEBUG = "true" %> In the @ control command to define this page to save the containing control code (II) *. ascx files, such as. ascx. (iii ). use: Header <% @ register tagprefix = "myfirstcontrol" tagname = "mylbl" src = ". axcs "%> // tagprefix is the control prefix. For example, ASP // tagname in aspextbox is used to specify the name of the custom control. // SRC: <myfirstcontrol: mylbl runat = "server" id = "allmine" mytext = "succeeded"/> B. use C # To create a custom control (I ). create a code-only file, inherit the control class of the base class, and save it *. CS, such as. CS. (ii ). compile the code to generate an assembly: CSC/tbrary/R: system. DLL, system. web. dll. CS // library tells C # The Compiler generates an assembly // R: system. DLL system. web. DLL tells C # That the compiler references the specified assembly (III ). place the generated DLL file in the bin directory (IV ). usage: <% @ register tagprefix = "mine" namespace = "myowncontrols" assembly = "A" %>22. Precautions for composite controls:Public class mycompositin: control, inamingcontainer // inamingcontainer: if multiple control instances exist on the page, this interface can uniquely mark this for every {}/instance. ensurechildcontrols (); // indicates that the child controls of the composite control are displayed on the page. This method checks whether the server control contains the child control createchildcontrols.23. When will button/linkbutton/imagebutton/hyperlink be used?1. The buttons and imagebutton are used to pass data back to the server. 2. hyperlink is used to navigate between pages. 3. linkbutton is used to save data to the server or access the data on the server.24. Tracking and debuggingTracking: 1. page-level tracing: The following page commands are included at the beginning of the page: <% @ 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"); // with trace. write is the same, but the font is red to check whether trace example: If (trace. isenabled) {trace. warn ("tracking enabled")} 2. application-level tracking: in the web. <system. <trace enabled = "true" pageoutput = "true"/>25. set {
Function onclick ()
{
Tagshow (Event)
}
} "> Cache:
1. output cache: I. page settings: Add <% @ outputcache duration = "120" varybyparam = "NONE" %> to the beginning of the page to be cached. Note: within two minutes after requesting this page, output content unchanged II. programming Method setting: mainly uses the class system. web. methods In the httpcachepolicy class (1 ). response. cache. setexpires (datetime. now. addseconds (120); // you must specify the expiration time in this method, such as two minutes (2 ). response. cache. setexpires (datetime. now. addseconds (120); response. cache. setslidingexpiration (true); // "adjustable expiration", mainly used for scenarios with high access volume but traffic balance: the first sentence sets the cache expiration time, the second line opens the sliding expiration (adjustable expiration ). 2. data Cache: (1 ). dataview mysource; (2 ). assign values to mysource; (3 ). cache ["mycache"] = mysource; (4 ). mysource = (dataview) cache ["mycache"]26. Deployment: directly copy to the product server.Copy statement: xcopy <source_path> <destination_path> // xopy only accepts physical paths, not virtual paths.

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.