自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

編寫C#日期時(shí)間控件的幾種方法

開發(fā) 后端
做Web頁面很多要用到日期輸入,.NET自帶的日歷控件每次都需要與服務(wù)器交互很不方便。為了圖省事自己開發(fā)了一個(gè)C#日期時(shí)間控件。

參照用JavaScript編寫的日期選擇,將其中的JavaScript部分寫入控件中就可以了。C#日期時(shí)間控件代碼不復(fù)雜,拿出來大家共享以下。大家?guī)兔φ艺褺ug,提提改進(jìn)意見。

實(shí)現(xiàn)效果如下:

C#日期時(shí)間控件實(shí)現(xiàn)效果

 Bug:控件放到frame 的頁面里面使用得時(shí)候就會(huì)出錯(cuò):“parent.event 為空或不是對(duì)象”
將InputCalendar.cs中output.WriteLine("parent.event.cancelBubble=true;");一句去掉即可。
這一句的意義是:設(shè)置或獲取當(dāng)前事件是否要在事件句柄中向上冒泡。當(dāng)前應(yīng)用中好像沒有用,所以去掉也不要緊。

如何增加Autopostpack功能:

  1. if (autopostback==true )   
  2. {   
  3. output.WriteLine ("javascript:"+Page.GetPostBackEventReference(this)+";");   
  4. }   
  5. //添加了一個(gè)AUTOPOSTBACK功能。  

在頭部加上如下代碼,即可實(shí)現(xiàn)選擇Autopostpack功能了。

  1. private bool autopostback=true;   
  2. [Bindable(true),   
  3. Category("Appearance"),   
  4. DefaultValue(true)]   
  5. public bool AutoPostBack   
  6. {   
  7. get   
  8. {   
  9. return autopostback;   
  10. }   
  11. set   
  12. {   
  13. autopostback=value;   
  14. }   

解決在用戶C#日期時(shí)間控件控件中取值問題:

將原來的C#日期時(shí)間控件:

  1. output.AddAttribute(HtmlTextWriterAttribute.Id,this.ID);   
  2. output.AddAttribute(HtmlTextWriterAttribute.Name,this.ID);  

改為:

  1. output.AddAttribute(HtmlTextWriterAttribute.Id,this.UniqueID);   
  2. output.AddAttribute(HtmlTextWriterAttribute.Name,this.UniqueID);  

將原來的C#日期時(shí)間控件:

  1. output.AddAttribute(HtmlTextWriterAttribute.Id,this.ID); output.AddAttribute(HtmlTextWriterAttribute.Name,this.ID); 改為: output.AddAttribute(HtmlTextWriterAttribute.Id,this.UniqueID); output.AddAttribute(HtmlTextWriterAttribute.Name,this.UniqueID); 

 

【編輯推薦】

  1. C# 4.0 Dynamic關(guān)鍵字全解析
  2. 淺談C#中構(gòu)造函數(shù)和成員函數(shù)
  3. C#回調(diào)函數(shù)及API應(yīng)用淺析
  4. 詳解C# Object.Equals函數(shù)
  5. C#調(diào)用Windows API函數(shù)
責(zé)任編輯:彭凡 來源: yaosansi.com
相關(guān)推薦

2009-09-24 14:59:38

C#編寫COM組件

2009-08-31 09:19:31

c#隱藏窗口

2013-02-22 09:54:15

C#Excel讀取Excel

2009-08-05 13:34:18

C#日期相減

2009-09-01 18:35:53

C#判斷文件存在

2009-07-30 15:57:30

C#時(shí)間

2009-07-30 16:40:03

C#日期格式化

2009-08-06 16:58:40

C#編寫ActiveX

2009-08-28 15:05:35

C#編寫Calenda

2009-08-27 14:32:15

C#編寫ActiveX

2009-08-25 17:31:57

C#讀取文件

2010-01-22 14:46:25

C++語言

2009-07-30 16:27:33

C#比較時(shí)間

2009-08-03 13:34:06

自定義C#控件

2009-09-14 18:11:23

C#排序方法

2024-08-23 09:00:18

開發(fā)跨域請(qǐng)求

2009-07-30 16:56:14

C#時(shí)間控件

2009-08-06 17:24:08

C#字符串

2009-08-25 14:59:36

ASP.NET和C#連

2009-08-28 16:31:21

C# treeview
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)