Asp.net Learning

Source: Internet
Author: User
1. Calculate the number of days between two dates
System. DateTime dtA = (DateTime) this. StartDate. Text;
System. DateTime dtB = (DateTime) this. EndDate. Text;
TimeSpan c = db-da;
Response. Write (c. TotalDays );
2. string format required for date conversion
Calendar2.SelectedDate. ToString ("yyyy-MM-dd"); after the calendar control selects a date, it is converted to the required string format. The format here is case-sensitive rotation. I don't understand why the month is case-sensitive, but it is not supported in lower case.
3. Implementation of control-level attributes
 

1 # region control attributes
2 // true-show all columns false-hide some columns
3 public bool IsVisible
4 {
5 get
6 {
7 return (ViewState ["IsVisible"] = null )? True: bool. Parse (ViewState ["IsVisible"]. ToString ());
8}
9 set
10 {
11 ViewState ["IsVisible"] = value;
12}
13}
14
15 // display data type 0-submit 1-to-do
16 public int ShowType
17 {
18 get
19 {
20 return (ViewState ["ShowType"] = null )? 0: int. Parse (ViewState ["ShowType"]. ToString ());
21}
22 set
23 {
24 ViewState ["ShowType"] = value;
25}
26}
27 # endregion
28

I have never understood the usage of viewstate before. Now I have used it and finally understood it. It seems that it is really important to accumulate experience in practice :)

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.