Repeater
<Span>
<% # Eval ("date", "{0: dd Mmm yyyy}") %>
</Span>
Datetime. Now. tostring ("yyyy/mm/DD ")
Bytes ---------------------------------------------------------------------------------------------------------------------
Multi-level master page
If there are multiple layers, you can only open <% @ master> In The Source view.
<% @ Materpagefile = %>
For multiple layers, an intermediate page is generated with the <asp: content> tag, which is associated with the <asp: contentplaceholder> tag on the master page.
The <asp: content> tag contains the <asp: contentplaceholder> tag, which is used to contain the next page.
Example
This section contains threeCodeExample. The first sample code demonstrates how to create a nested master page .. The second sample code demonstrates how to reference the master page created in the first sample code. The third sample code demonstrates how to use the content page to reference the master page created in the second sample code.
The following code example shows how to create a nested master page and shows the parent master page named parentmasterpage_1.
C # copy the Code <% @ master language = "C #" %>
<! Doctype HTML public "-// W3C // dtd xhtml 1.1 // en" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<HTML>
<Head runat = "server">
<Title> nested master page example </title>
</Head>
<Body>
<Form ID = "form1" runat = "server">
<H1> This is content in the parent master page. <Div>
<Asp: contentplaceholder id = "contentplaceholder1" runat = "server">
</ASP: contentplaceholder>
</Div>
</Form>
</Body>
</Html>
The following code example demonstrates how to use the nested master page named childmasterpage_1 to reference the master page created in the previous code example.
C # copy the Code <% @ master language = "C #" masterpagefile = "~ /Parentmasterpage_1cs.master "%>
<Asp: Content runat = "server" contentplaceholderid = "contentplaceholder1">
<H2> this is the content of a nested master page. </H2>
<Div>
<Asp: contentplaceholder id = "contentplaceholder2" runat = "server">
</ASP: contentplaceholder>
</Div>
</ASP: content>
The following code example demonstrates how to use the content page named contentpage to reference childmasterpage_1 created in the previous code example.
C # copy the Code <% @ page Language = "C #" masterpagefile = "~ /Childmasterpage_1cs.master "Title =" untitled page "%>
<Asp: Content runat = "server" contentplaceholderid = "contentplaceholder2">
This is the content of a content control.
</ASP: content>
Like theme, masterpage can format the display mode of website controls. masterpage can define the same part of different webpages in a website, such as the pattern, page header, footer, and navigation bar. You can define these controls on a masterpage, and other webpages can inherit this masterpage. The inheritance is reflected in that the public parts of these webpages are the same, and the difference is that masterpage has a contantplaceholder, which defines a region that can be inherited by other pages, this area can be used by other pages to place your own controls. When you create a web page, select the master and then select the master.
Note: Application Program You can specify the default master page in Web. config as follows:
<Configuration>
<System. Web>
<Pages masterpagefile = "~ /Foo. Master "/>
</System. Web>
</Configuration>
Okay. masterpage is coming. Writing the page is simple. You can fill in contentplaceholder on the contentpage page... the problem is... now, some of my pages use some JavaScript (placed in a calendar. in JS), what should I do? Ha, after 0.01 seconds, I thought of "solution": Isn't it enough to write a connection to contentpage? For example:
script type =" text/JavaScript " SRC = ".. /.. /.. /JS/calendar. JS " script >
(Note: SRC is the relative path from contentpage to JS file !!!) Good, young man. I didn't directly drop over one thousand lines of js code to the page. :) but the problem is, where do you want to drop this sentence? The question is, of course, put it on the "head" of the page... haha. Now there are no headers in contentpage, And the heads are all in masterpage. Is it thrown out of contentplaceholder of contentpage? No, HTML cannot be parsed...
Google once learned the following knowledge: To put it bluntly, masterpage is the control in the original page, but it is originally a page wrapped with controls, and now it is a page wrapped with controls :) For the client-brower, he knows nothing about masterpage. when the customer requests a page, Asp.net runtime finds that the page uses masterpage, so the two independent parts are integrated according to the placeholder-contentplaceholder and returned to the customer, this process is transparent to customers ....
In this case, it is very simple. Isn't it enough to put the above sentence in masterpage like JS? (Note that at this time, Src cannot follow the relative path from masterpage to JS. Why? Just now? :) OK. successful. but ".. /.. /.. /"this relative path is definitely a problem. Writing this path is completely for my contentpage. That is to say, if the contentpage of other directories cannot use this JS, of course this will not work, change him to an absolute path Bay "~ /JS/... ". However, it is not a solution that can be taken for granted. Asp.net cannot find JS? Dizzy... after trying for a long time, the problem cannot be solved after changing for a long time. it is not acceptable to place a relative path for some pages on masterpage. in desperation, we can only set up shortcuts and finally find that it is okay to put the above JS connection words in a contentplaceholder in each contentpage. the problem is solved, and the idea is reasonable, but the practice is too ugly ..... no way. It's crazy ..
Generally, there are three methods to express the link path: absolute path, relative path, and root directory-based path. In addition, for ASP. NET Server controls, you can also use "~" To replace the root directory.
In masterpage and user controls, images are often used as backgrounds or beautiful buttons. However, when you specify the SRC or background of an image, errors often occur due to link paths.
1. Use absolute path: an absolute file path like "D: \ XXX \ xxx.gif" is generally not desirable. You can consider using the URL method to write it as http: // xxxx/XX/xxx.gif ". But the disadvantage is not conducive to transplantation, for example, the current site address is http://www.xxx.net, if one day the site is more the http://www.xxx.com, then all the link addresses are invalid, need to change, difficult to maintain.
2. use relative path: Use the path relative to the page location, such as ".. \ images \ xxx.gif ", so that the masterpage and user control can be correctly displayed, but if the page inheriting masterpage is put in a different folder, or the page using the user control is not in the same folder, the correct image location will not be found on this page!
3. based on the root directory path: such as: <a href = "/XXX/xxx.gif"> in ASP. during net2.0 debugging, the virtual directory is not created and cannot be correctly displayed (I am not very sure, I did not confirm ^_^ ). "~" Cannot be used on HTML Tag elements of non-server controls. To specify the path.
So what should we do to make the image visible during design? I used CSS to do this. For the elements and controls to display the image, we can write a simple CSS to locate the image, because the position of the CSS file is generally not changed (in app_theme/themename/xxx.css ), this method also works.
. Hidebar
{
Height: 56px;
Width: 5px;
Cursor: hand;
Background-image: URL (.../../images/xxx.gif );
} Then, we only need to fill in hidebar in the cssclass of the corresponding elements and controls, so that every page inheriting masterpage or using user controls can correctly display images.
I think there should be other better methods, and I hope someone can give me some advice.
Bytes ----------------------------------------------------------------------------------------------
Set
Arraylist: dynamically adjusts the size of an item when it is added. It is most suitable for storing custom object types when data changes frequently, for example, during frequent insertion or deletion.
Hashtable: best suited for data that does not change frequently, especially for frequently queried data
Queue (first-in-first-out): This set should be used when data needs to be sorted in order.
Sortedlist (sequential bucket key/value)
Frequently changed data
STACK: This set should be used when data needs to be sorted in reverse order.
Stringcololection (string set): a strong arraylist, used to store strings in any order and frequently changed.
Stringdictionary: a strong type of hashtable. Therefore, when it is used as a string to be sorted, and these strings do not change frequently.
When storing strings, there are stringcololection and stringdictionary because they only store strings
Bytes ----------------------------------------------------------------------------------------------------------------
Lable1.text. Split (splitchars. tochararray ())
Text returns the string split method of the string class. The parameter passed to the string is not the splitchars variable itself,
Instead, the splitchars that has been converted into a character array (use tochararray ())
The split method must be of the character array type.
If the number of elements does not change, it is best to use an array; otherwise, use a set
The use of attributes instead of public variables is based on the object-oriented abstraction principle. Private variables are used as internal memory, and attributes are only the methods for accessing internal variables in user terms of this class.
Bytes -------------------------------------------------------------------------------------------------------------------
System. Collections. Generic
Whenever you need a set of custom classes, it is best to use a generic set to improve code readability and reduce potential errors.
Private items as new list (of cartitem)
Cartitem This is a custom class with variables
Dim items as new list (of cartitem)
Dim item as cartitem (...)
Items. Add (item)
This list is a clear data type and cannot perform the following operations
Items. Add ("ffff ")
Bytes -------------------------------------------------------------------------------------------------------------
Incomplete partial class indicates that the background code file and web form are integrated into a class file during compilation.
Asp.net 2.0 user code ---- Microsoft intermediate language -- Common Language Runtime --- executable code
Compilation Method:
Pre-runtime Compilation: the background code file is compiled into an assembly and saved in the \ bin directory. Compile the web forms and. aspx pages as needed
Full runtime compilation (compile at full run time): the background code file and all other related code are stored in the app_code folder, and then ASP. NET 2.0 creates and maintains
Reference of an assembly (generated from these files at runtime.
Deployment pre-Compilation