摘要:对身份证号码的分析同对学号的分析类似。正文:这里认为身份证号是18位的。在页面上添加一个Label控件,一个TextBox控件,一个Button控件,一个Literal控件。Label控件的Text属性设为“身份证号:”,Literal控件将显示身份证号里的信息。关键还是在Button控件的Click()事件中。Button控件的Click()事件: string strID = txtID.Text; if (!txtID.Visible) { txtID.Visible = true; } try { string strYear = strID.Substring(6,4); // 年 string strMonth = strID.Substring(10,2); // 月 string strDay = strID.Substring(12,2); // 日 Literal1.Text = "您的生日是:"+strYear+"年"+strMonth+"月"+strDay+"号"; } catch { Response.Write("程序有错误!"); } finally { } |