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

成都創(chuàng)新互聯(lián)公司專注于企業(yè)全網(wǎng)整合營銷推廣、網(wǎng)站重做改版、普洱網(wǎng)站定制設(shè)計、自適應(yīng)品牌網(wǎng)站建設(shè)、html5、商城網(wǎng)站制作、集團(tuán)公司官網(wǎng)建設(shè)、外貿(mào)網(wǎng)站制作、高端網(wǎng)站制作、響應(yīng)式網(wǎng)頁設(shè)計等建站業(yè)務(wù),價格優(yōu)惠性價比高,為普洱等各大城市提供網(wǎng)站開發(fā)制作服務(wù)。
實(shí)現(xiàn)效果如下:
Bug:控件放到frame 的頁面里面使用得時候就會出錯:“parent.event 為空或不是對象”
將InputCalendar.cs中output.WriteLine("parent.event.cancelBubble=true;");一句去掉即可。
這一句的意義是:設(shè)置或獲取當(dāng)前事件是否要在事件句柄中向上冒泡。當(dāng)前應(yīng)用中好像沒有用,所以去掉也不要緊。
如何增加Autopostpack功能:
- if (autopostback==true )
- {
- output.WriteLine ("javascript:"+Page.GetPostBackEventReference(this)+";");
- }
- //添加了一個AUTOPOSTBACK功能。
在頭部加上如下代碼,即可實(shí)現(xiàn)選擇Autopostpack功能了。
- private bool autopostback=true;
- [Bindable(true),
- Category("Appearance"),
- DefaultValue(true)]
- public bool AutoPostBack
- {
- get
- {
- return autopostback;
- }
- set
- {
- autopostback=value;
- }
- }
解決在用戶C#日期時間控件控件中取值問題:
將原來的C#日期時間控件:
- output.AddAttribute(HtmlTextWriterAttribute.Id,this.ID);
- output.AddAttribute(HtmlTextWriterAttribute.Name,this.ID);
改為:
- output.AddAttribute(HtmlTextWriterAttribute.Id,this.UniqueID);
- output.AddAttribute(HtmlTextWriterAttribute.Name,this.UniqueID);
將原來的C#日期時間控件:
- output.AddAttribute(HtmlTextWriterAttribute.Id,this.ID); output.AddAttribute(HtmlTextWriterAttribute.Name,this.ID); 改為: output.AddAttribute(HtmlTextWriterAttribute.Id,this.UniqueID); output.AddAttribute(HtmlTextWriterAttribute.Name,this.UniqueID);
當(dāng)前標(biāo)題:編寫C#日期時間控件的幾種方法
當(dāng)前鏈接:http://m.fisionsoft.com.cn/article/cccpcdj.html


咨詢
建站咨詢
