Preface: Take a note and continue to record my basic ASP. NET knowledge.
- The radiobutton control is rendered as <input type = "radio"/> on the client side. Like the server side control, the radiobutton control can also be grouped by the groupname attribute.
- The button control is rendered on the client as <input type = "Submit"/>
- The linkbutton control is rendered on the client as <a href = "javascript :__ dopostback"/>
- The imagebutton control is a button that allows you to set imageurl. It is rendered on the client as <input type = "image"/>
Similarities: You can set the onclientclick attribute to "Return confirm ('Are you sure you want to delete it? ')";
- The panel control is rendered as a div on the client. If the groupingtext attribute is set, the panel control is rendered as <fieldset> <legend> Settings </legend> </fieldset>, that is, the groupbox effect.
- The hyperlink control is rendered as a <A/> flag on the client.
You can set the properties navigateurl = "" and target = "". If you set the imageurl attribute, it is rendered to <a href = ""> <image/> </a>.
- The fileupload control is rendered on the client as <input type = "file">.
Generally, the code for uploading files is written in this way.
If (fileupload1.hasfile ())
{
String uploadpath = server. mappath ("~ /Upload /");
Fileupload1.saveas (uploadpath + fileupload1.filename );
}
- In general, controls are divided into three types:
1) HTML controls
2) ASP. NET Server-side controls
3) HTML control with runat = "server"
- Verify controls
1) requirefieldvalidator: A required field for non-empty server verification. common attributes include errormessage, controltovalidate, and initialvalue. you can write if (this. isvalide ){...}
2) rangevalidator: determines whether the value is between the given maximum value (maximumvalue) and minimum value (minimumvalue). The comparable data types include string, Int, and currency.
3) comparevalidator: used to compare whether the relationship between two values meets the requirements or data of the specified type. Comparison operators: <,>, = ,! =. Common attribute: valuetocompare: Compare with which value, controltocompare: Compare with which control.
4) regularexpressionvalidator: a regular expression used to verify that the data meets the requirements. Common attribute: validationexpression: defines a regular expression.
5) customvalidator: used for custom verification in special cases.
6) Note: (1) almost all verification controls must be verified on the client and server.
(2) group verification controls: validationgroup
(3) Whether to trigger the verification event: causevalidation: false, indicating that the verification event is not triggered
(4) modify and verify whether the control is placeholder: Display is set to dynamic or static.
- Data Binding
1) Example: <itemtemplate> <% # eval ("ID") %> </itemtemplate>
2) The repeater data control is used to bind the traversal display of data. Of course, you can also use the foreach statement to hand-Write the data.
3) Other Repeater control templates
(1) <alternatingitemtemplate> set different styles of the row, that is, the style of the even row.
(2) The (3) <seperatortemplate>, the delimiter between the two data items.
- The database only stores the image path, resolveclienturl ("~ /Images/+ URL ");
- The controls placed in the <itemtemplate> template cannot be operated directly in the C # code in the background. You must first find the controls by ID, such as E. Item. findcontrol ("txtname ");
- The Repeater control is generally used to display data only, while the listview control is used to add, delete, change, and production operations.
- Eval () is a one-way binding, used to read data in the database; BIND () is a two-way binding, which can read the values in the database to the page and upload user values to the database.
- Considerations for the listview control:
(1) automatically generated styles should be extracted into CSS styles rather than inline styles;
(2) in <itemtemplate>, the <asp: Label> control is generally not required to display read-only data and output data directly.
(3) <layouttemplate> must have a server control with ID itemplaceholder. Change the English fields automatically generated in the header to Chinese. Useless IDs must be deleted, and no need to be displayed.
- Note the following in the itemdatabound event:
(1) determine the data Row Type E. Item. itemtype = listviewitemtype. datarow
(2) obtain the corresponding rowview listviewdataitem lvdataitem = (listviewdataitem) E. Item; datarowview rowview = (datarowview) lvdataitem. dataitem;
(3) When using findcontrol, you should pay attention to the alternatingitemtemplate problem.
- Differences between listview and gridview
(1) The gridview can only be rendered as a table.
(2) listview can be rendered to both table and <ul> <li>
- The dropdownlist control binds the selectedvalue attribute, for example, selectedvalue = "<% # eval ('txtname') %>"
- If the page front-end does not involve adding, deleting, modifying, and querying interactive information, you can disable viewstate in either of the following ways:
(1) Disable viewstate on the page as a whole: Add enabelviewstate = "false" to the <page> label on the top"
(2) Disable viewstate for the specified control: Add enabelviewstate = "false" to the property of the control"
- Website Performance Tuning
(1) cache is the first method for optimizing website performance;
(2) index is the first way to optimize database performance;
- How to Set page cache: In the page header area, set <% @ outputcache duration = "20" varybyparam = "NONE" (this is variable and can be set as a parameter: ID; num; age, etc.) %>
- The data cache setting method sets attributes for objectdatasource,
(1) enablecaching = "true"
(2) cacheduration = "20"
Written behind: Mr. Lu Xun has a saying, "Where is a genius? I spent all my work and study on coffee! "I agree very much that diligence is good training. Now, let's get here today!