对“学号”、“身份证”的数字分析(2) - 中国WEB开发者网络 (http://www.webasp.net) -- 技术教程 (http://www.webasp.net/article/) --- 对“学号”、“身份证”的数字分析(2) (http://www.webasp.net/article/24/23754.htm) |
| -- 作者:未知 -- 发布日期: 2005-05-11 |
| 摘要: 对身份证号码的分析同对学号的分析类似。 正文: 这里认为身份证号是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 { } 显示效果图: |
| webasp.net |