Some tips for calendar use

Source: Internet
Author: User

When I recently finished, I thought of using calendar to create a calendar that showed important event hints. Because of the limited area, this calendar can only display dates and so on. Therefore, you cannot add text to it, and you can only add a hyperlink below it to trigger the alert event to prompt the message.

    • First set up a data table for storing messages, which need to add the appropriate reminder date column, and the corresponding message column, do not repeat.
    • Create two more interfaces, one to add the deleted data in the background and the other to display the calendar.
☆: Date Event Add management

Front desk: A Label, a Calendar, a Textbox, a button, and a Gridviewthat can provide a delete column.

Background:

1     protected voidCalendar1_SelectionChanged (Objectsender, EventArgs e)2     {3Label1.Text =Calendar1.SelectedDate.ToShortDateString ();4     }5     protected voidButton1_Click (Objectsender, EventArgs e)6     {
This uses layer three to add data to the database7DateTime Day =calendar1.selecteddate;8 stringmsg =TextBox1.Text;9 TenCalender Calender =Newcalender (); OneCALENDERBLL BLL =NewCALENDERBLL (); A -Calender. Msgtime =Day ; -Calender. UserID = session["UserID"]. ToString (); theCalender. MSG =msg; -Calender. Createtime =DateTime.Now; - - if(!BLL. Exists (day)) + { - if(BLL. ADD (calender)) + { AResponse.Write ("<script>alert (' Release success! ');"); at } - Else - { -Response.Write ("<script>alert (' Publish failed! ') </script>"); - } - in } - Else to { +Response.Write ("<script>alert (' The date time already exists! ') </script>"); - } the } * protected voidCalendar1_dayrender (Objectsender, Dayrendereventargs e) $ {Panax Notoginseng if(e.day.date<DateTime.Now) - { theE.day.isselectable =false;//used to control whether the day can be selected + } A}
☆: Front Display interface

Primarily for the Calendar control

1  protected voidCalendar1_dayrender (Objectsender, Dayrendereventargs e)2     {3DateTime today =Datetime.today;4DataSet dt =NewDataSet ();5         6         //here, a three-tier architecture is used to get the date with the message event and the corresponding message from the database7CALENDERBLL CALBLL =NewCALENDERBLL ();8 //Note the use of the AddDays method to traverse events that are 30 days before and after the day9         stringBegin = Today. AddDays (Convert.todouble (- -)). ToString ();Ten         stringto = today. AddDays (Convert.todouble ( -)). ToString (); One  ADT =CALBLL. GetList (begin, to); -         if(dt! =NULL) -         { the              for(inti =0; i < dt. tables[0]. Rows.Count; i++) -             { -                 stringDay = dt. tables[0]. rows[i]["Msgtime"]. ToString (); -                 if(E.day.date.tostring (). Substring (0,Ten) = = Day. Substring (0,Ten)) +                 { -E.cell.backcolor =System.Drawing.Color.Red; +                     //The following is a foolish attempt, and if you do not modify Cell.text, a number appears next to the date, although it can be changed to a flag or picture, but it affects the layout A                     //half a day to understand, why not on the original basis to add to him add the link ah, really brain to think unclear.  at                     //E.cell.controls.add (New LiteralControl ("<a href=" javascript:void (0) ' onclick= "+ '" ' + "showmsg ('" +dt. Tables[0]. rows[i]["MSG"]+ "')" + ' "' +" > "+e.day.daynumbertext+" </a> "); -E.cell.text ="<a href= ' javascript:void (0) ' onclick="+'"'+"showmsg ('"+dt. tables[0]. rows[i]["MSG"]+"')"+'"'+">"+e.day.daynumbertext+"</a>"; -                 } -             } -}

Some tips for calendar use

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.