• 软件测试技术
  • 软件测试博客
  • 软件测试视频
  • 开源软件测试技术
  • 软件测试论坛
  • 软件测试沙龙
  • 软件测试资料下载
  • 软件测试杂志
  • 软件测试人才招聘
    暂时没有公告

字号: 小 中 大 | 推荐给好友 上一篇 | 下一篇

日曆控件

发布: 2007-6-30 18:56 | 作者: admin | 来源: | 查看: 18次 | 进入软件测试论坛讨论

领测软件测试网 1.UCCalendar.ascx
<%@ control Language="vb" AutoEventWireup="false" Codebehind="UCCalendar.aspx.vb" Inherits="WebApplication1.UCCalendar"%>
<FONT face="新細明體">
<script language="javascript">
function CheckDate(o){
var Str=new String;
var StrEnd = new String;
Str = o.value;
if (Str != "" )
{
if (chkformat(Str) == false)
{
o.focus();
}
}
}



function chkformat(datestr)
{

var lthdatestr
lthdatestr= datestr.length ;
var tmpy="";
var tmpm="";
var tmpd="";
//var datestr;
var status;
status=0;

for (i=0;i<lthdatestr;i++){
if (datestr.charAt(i)== ‘’/‘’){
status++;
}
if (status>2){
alert("日期錯誤");
return false;
}
if ((status==0) && (datestr.charAt(i)!=‘’/‘’)){
tmpy=tmpy+datestr.charAt(i)
}
if ((status==1) && (datestr.charAt(i)!=‘’/‘’)){
tmpm=tmpm+datestr.charAt(i)
}
if ((status==2) && (datestr.charAt(i)!=‘’/‘’)){
tmpd=tmpd+datestr.charAt(i)
}
}

year=new String (tmpy);
month=new String (tmpm);
day=new String (tmpd)
//tempdate= new String (year+month+day);
//alert(tempdate);
if ((tmpy.length!=4) || (tmpm.length>2) || (tmpd.length>2))
{
alert("日期錯誤");
// alert("date");
return false;
}
if (!((1<=month) && (12>=month) && (31>=day) && (1<=day)) )
{
alert ("日期錯誤");
return false;
}
if (!((year % 4)==0) && (month==2) && (day==29))
{
alert ("日期錯誤");
return false;
}
if ((month<=7) && ((month % 2)==0) && (day>=31))
{
alert ("日期錯誤");
return false;
}
if ((month>=8) && ((month % 2)==1) && (day>=31))
{
alert ("日期錯誤");
return false;
}
if ((month==2) && (day==30))
{
alert("日期錯誤");
return false;
}

return true;
}

</script>
<div align="center"><asp:textbox id="txtCalendar" onblur="CheckDate(this)" runat="server" Width="181px"></asp:textbox><asp:button id="btnCandelar" runat="server" Text="...."></asp:button><asp:calendar id="Calendar1" runat="server" Width="208px" Height="200px" BorderWidth="1px" BackColor="White"
ForeColor="#003399" Font-Size="8pt" Font-Names="Verdana" BorderColor="#3366CC" CellPadding="1" ShowGridLines="True">
<TodayDayStyle ForeColor="White" BackColor="#99CCCC"></TodayDayStyle>
<SelectorStyle ForeColor="#336666" BackColor="#99CCCC"></SelectorStyle>
<NextPrevStyle Font-Size="8pt" ForeColor="#CCCCFF"></NextPrevStyle>
<DayHeaderStyle Height="1px" ForeColor="#336666" BackColor="#99CCCC"></DayHeaderStyle>
<SelectedDayStyle Font-Bold="True" ForeColor="#CCFF99" BackColor="#009999"></SelectedDayStyle>
<TitleStyle Font-Size="10pt" Font-Bold="True" Height="25px" BorderWidth="1px" ForeColor="#CCCCFF"
BorderStyle="Solid" BorderColor="#3366CC" BackColor="#003399"></TitleStyle>
<WeekendDayStyle BackColor="#CCCCFF"></WeekendDayStyle>
<OtherMonthDayStyle ForeColor="#999999"></OtherMonthDayStyle>
</asp:calendar></div>
</FONT>


2.UCCalendar.ascx.vb


Public Class UCCalendar

Inherits System.Web.UI.UserControl



#Region " Web Form 設計工具產生的程式碼 "



‘’此為 Web Form 設計工具所需的呼叫。

<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()



End Sub

Protected WithEvents Calendar1 As System.Web.UI.WebControls.Calendar

Protected WithEvents txtCalendar As System.Web.UI.WebControls.TextBox

Protected WithEvents btnCandelar As System.Web.UI.WebControls.Button



‘’注意: 下列預留位置宣告是 Web Form 設計工具需要的項目。

‘’請勿刪除或移動它。

Private designerPlaceholderDeclaration As System.Object



Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init

‘’CODEGEN: 此為 Web Form 設計工具所需的方法呼叫

‘’請勿使用程式碼編輯器進行修改。

InitializeComponent()

End Sub



#End Region



Public Property txtCanendar() As String

Get

Return Me.txtCalendar.Text

End Get

Set(ByVal Value As String)

Me.txtCalendar.Text = Value

End Set

End Property



Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

‘’在這裡放置使用者程式碼以初始化網頁

End Sub



Private Sub Calendar1_SelectionChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Calendar1.SelectionChanged

Me.txtCalendar.Text = Me.Calendar1.SelectedDate.ToShortDateString

Me.Calendar1.Visible = False

End Sub



Private Sub btnCandelar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCandelar.Click

If Me.Calendar1.Visible = True Then

Me.Calendar1.Visible = False

Else

Me.Calendar1.Visible = True

End If

End Sub

End Class



3.


延伸阅读

文章来源于领测软件测试网 https://www.ltesting.net/


关于领测软件测试网 | 领测软件测试网合作伙伴 | 广告服务 | 投稿指南 | 联系我们 | 网站地图 | 友情链接
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备2023014753号-2
技术支持和业务联系:[email protected] 电话:010-51297073

软件测试 | 领测国际 | ISTQB | ISTQB官网 | TMMi | TMMi认证 | 国际软件测试工程师认证 | 领测软件测试网