发送手机验证,存入系统缓存,5分钟失效 //6位随机数字做验证码 int Verified = new Random().Next(100000, 999999); //存入系统缓存,5分钟失效 Cache.Insert("MobileVerified_" + tbMobile.Text.Trim(), Verified, null, DateTime.Now.AddMinutes(5.0), System.Web.Caching.Cache.NoSlidingExpiration); protected void btnOK_Click(object sender, EventArgs e) { if (Cache["MobileVerified_" + tbMobile.Text.Trim()] != null) { if (Cache["MobileVerified_" + tbMobile.Text.Trim()].ToString() == tbMobileVerified.Text.Trim()) { _User.isMobileVerified = true; } } } 写系统日志: private static object lockWrite = new object(); public static void WriteLog(Type t, string errString) { errString = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + "| " + t.FullName + ":" + errString; if (!Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + @"/App_Log")) { Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + @"/App_Log"); } WriteTextFile(AppDomain.CurrentDomain.BaseDirectory + @"/App_Log/" + DateTime.Now.Date.ToString("yyyy-MM-dd") + ".txt", errString); } private static void WriteTextFile(string sName, string sLine) { lock (lockWrite) { try { StreamWriter writer = new StreamWriter(new FileStream(sName, FileMode.Append, FileAccess.Write), System.Text.Encoding.GetEncoding("GBK")); writer.WriteLine(sLine); writer.Close(); } catch (SystemException ex) { WriteLog(typeof(PublicFunction), ex.Message); } } } 加载Iframe <div id="clearing_right"> <div id="clearing_note" runat="server" align="center"> <!-- 创建一个 iframe 装载总控页面 --> </div> </div> System.Web.UI.HtmlControls.HtmlGenericControl frmProductIntro = new HtmlGenericControl(); frmProductIntro.ID = "frmSaas"; frmProductIntro.TagName = "iframe"; frmProductIntro.Attributes.Add("name", "frmSaas"); frmProductIntro.Style.Add(HtmlTextWriterStyle.Width, "798px"); frmProductIntro.Style.Add(HtmlTextWriterStyle.Height, "460px"); frmProductIntro.Style.Add(HtmlTextWriterStyle.OverflowX, "hidden"); frmProductIntro.Attributes.Add("scrolling", "yes"); frmProductIntro.Attributes.Add("frameborder", "0"); if (_User != null) { trMy.Style.Add(HtmlTextWriterStyle.Display, "inline"); } if (Shove._Web.Utility.GetRequest("type") != "") { string type = Shove._Web.Utility.GetRequest("type"); if (type == "1") { frmProductIntro.Attributes.Add("src", PublicFunction.GetShoveEimsSystemUrl() + "Sd_SearchSoft.aspx"); } else if(type == "2") { frmProductIntro.Attributes.Add("src", PublicFunction.GetShoveEimsSystemUrl() + "Sd_MySofts.aspx?UserName="+_User.Name+"&Pwd="+HttpUtility.UrlEncode( _User.Password)); } } //frmProductIntro.Attributes.Add("src", PublicFunction.GetShoveEimsSystemUrl() + "Apps.aspx?ID=" + Request["N"]);798px //frmProductIntro.Attributes.Add("onload", "document.all['frmProductIntro'].style.height=frmProductIntro.document.body.scrollHeight;"); clearing_note.Controls.Add(frmProductIntro); 动态创建Table: private void DrawNavigateMenu() { DataTable dt = new DAL.Tables.T_Site_Navigates().Open("*", "SiteID = " + _Site.ID + " AND isShow = 1", "[Order]"); if (dt != null && dt.Rows.Count > 0) { Shove._Web.Session.SetSession("Admin_SiteManage_Navigates", dt); Menu12.Visible = true; for (int i = 0; i < dt.Rows.Count; i++) { DataRow row = dt.Rows[i]; string Url = GetContentListUrl(tdNavigateMenus.Controls.Count.ToString(), row["ID"].ToString(), row["ContentType"].ToString(), row["TypeID"].ToString()) ; HtmlTable ht = new HtmlTable(); ht.ID = "Menu12_SubMenu" + (i + 1) + ""; ht.Attributes.Add("runat", "server"); ht.Attributes.Add("width", "180"); ht.Attributes.Add("cellspacing", "0"); ht.Attributes.Add("cellpadding", "0"); ht.Attributes.Add("border", "0"); HtmlTableRow hr = new HtmlTableRow(); HtmlTableCell htc1 = new HtmlTableCell(); HtmlTableCell htc2 = new HtmlTableCell(); htc1.Attributes.Add("width", "35"); htc1.Attributes.Add("height", "30"); htc1.Attributes.Add("align", "center"); htc1.InnerHtml = "<img src="images/clearing/9_dian.jpg" mce_src="images/clearing/9_dian.jpg" width='9' height='9' style="vertical-align: middle;" mce_style="vertical-align: middle;" />"; htc2.Attributes.Add("width", "145"); htc2.Attributes.Add("align", "left"); htc2.Attributes.Add("class", "blue14_2"); htc2.InnerHtml = "<a href="" +Url+ "" mce_href="" +Url+ "">" + row["Name"].ToString() + "</a>"; hr.Cells.Add(htc1); hr.Cells.Add(htc2); ht.Rows.Add(hr); tdNavigateMenus.Controls.AddAt(tdNavigateMenus.Controls.Count, ht); if (i == 0) { aFirst.HRef = Url; aFirst2.HRef = Url; } } } }