因为数据库正在使用,所以无法获得对数据库的独占访问权---还原或删除数据库的解决方法:
ALTER DATABASE [datebase] SET OFFLINE WITH ROLLBACK IMMEDIATE
ALTER database [ datebase] set online
objiect 转化为 model
mh_reguserInfoModel regUserInfo = (mh_reguserInfoModel)HttpContext.Current.Session["wcm_web_shangHaiMhRegLoginInfo"];
session转化
ReguserLoginBLL.userDic[regUserInfo.Id] = HttpContext.Current.Session.SessionID;
ReguserLoginBLL.sessionDic[HttpContext.Current.Session.SessionID] = regUserInfo.Id
IndexOf用法
int nPosEnd = sContent.IndexOf(sTemp)
sContent为<title>sdfg</title>
sTemp 为</title>
sContent.IndexOf(sTemp) 为<title>sdfg
nPosEnd 为11
*1.Indexof(*2)取得是*1里面除了*2的字符的个数
#region
///清空客户端页面缓存
/// 清空客户端页面缓存 ///
public static void ClearClientPageCache()
{
HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.Expires = 0;
HttpContext.Current.Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);
HttpContext.Current.Response.AddHeader("pragma", "no-cache"); HttpContext.Current.Response.AddHeader("cache-control", "private");
HttpContext.Current.Response.CacheControl = "no-cache";
}
#endregion
js 前台赋值传给后台
利用隐藏域作为中间介质中转
<input id="Hidden1" type="hidden" runat="server"/></body>
function get()
{
document.getElementById("Hidden1").value="aaa";
}
后台:
string s=Hidden1.Value;
验证码
<td style="width: 190px;" align="right">
<input class="inp2" id="w_inputCheck" type="text" value="验证码" onFocus="this.value=''" onBlur="if(!value){value=defaultValue;}" style="width: 85px; height: 18px" /></td>
<td><a onclick="changeImage1()"><asp:Image runat="server" Style="cursor: hand" ID="w_imageCheck" ImageUrl="/wcm/cswsp/public/ValidateCode.aspx"></asp:Image></a><a onclick="changeImage1()" style="cursor: hand">换一张?</a>
</td>
JS
function changeImage1()
{
document.all.w_imageCheck.src = "/wcm/outsite/default/ValidateCode.aspx?aa=" + Math.random();
document.all.w_inputCheck.focus();
}
ValidateCode.aspx页面
protected void Page_Load(object sender, EventArgs e) { string he; string checkCode = CreateRandomCode(4, out he); Session["wcm_web_checkCode"] = he.ToString(); CreateImage(checkCode); } /// <summary> /// 生成随即验证码 /// </summary> /// <param name="codeCount">验证码位数</param> /// <returns></returns> private string CreateRandomCode(int codeCount, out string sum) { string str = "abcdefghijkmnpqrstuvwxyz23456789ABCDEFGHIJKLMNPQRSTUVWXYZ"; string result = ""; Random rand = new Random(); for (int i = 0; i < codeCount; i++) { result += str[rand.Next(str.Length)]; } sum = result; return result; } /// <summary> /// 生成噪点验证码图片 /// </summary> /// <param name="checkCode"></param> private void CreateImage(string checkCode) { if (checkCode == null || checkCode.Trim() == String.Empty) return; System.Drawing.Bitmap image = new System.Drawing.Bitmap((int)Math.Ceiling((checkCode.Length * 17.5)), 35); Graphics g = Graphics.FromImage(image); try { //生成随机生成器 Random random = new Random(); //清空图片背景色 g.Clear(Color.White); //画图片的背景噪音线 for (int i = 0; i < 5; i++) { int x1 = random.Next(image.Width); int x2 = random.Next(image.Width); int y1 = random.Next(image.Height); int y2 = random.Next(image.Height); g.DrawLine(new Pen(Color.Silver), x1, y1, x2, y2); } Font font = new System.Drawing.Font("宋体", 20, (System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic)); System.Drawing.Drawing2D.LinearGradientBrush brush = new System.Drawing.Drawing2D.LinearGradientBrush(new Rectangle(0, 0, image.Width, image.Height), Color.Blue, Color.DarkRed, 1.2f, true); g.DrawString(checkCode, font, brush, 2, 2); //画图片的前景噪音点 for (int i = 0; i < 10; i++) { int x = random.Next(image.Width); int y = random.Next(image.Height); image.SetPixel(x, y, Color.FromArgb(random.Next())); } //画图片的边框线 g.DrawRectangle(new Pen(Color.Silver), 0, 0, image.Width - 1, image.Height - 1); System.IO.MemoryStream ms = new System.IO.MemoryStream(); image.Save(ms, System.Drawing.Imaging.ImageFormat.Gif); Response.ClearContent(); Response.ContentType = "image/Gif"; Response.BinaryWrite(ms.ToArray()); } finally { g.Dispose(); image.Dispose(); } }
根据条件控制行的显示隐藏<tr></tr>
<%if(aStatus==true){%>
<tr>
<td colspan="2" height="30px" align="center"></td>
</tr>
<%}%>
后台.cs页面
public bool bStatus;
if(a>0){
bStatus=true;
}else{
bStatus=false;
}
历史记录
<div class="centerbox">
<%=bfHistory%>
</div>--前台用一个div显示出来--
DataTable historyClass = fileBLL.GetHistory(userId);
foreach (DataRow dr in historyClass.Rows) --循环遍历每一行--
{
bfTime = Convert.ToDecimal(dr["study_time"]);--获取这一行的study_time这个字段的值--
//bfTime =dr["study_time"];
bfTime = Math.Floor(bfTime);
second = Convert.ToInt32(bfTime);
// second= bfTime / 1000;
if (second > 60)
{
minute = second / 60;
if (minute > 60)
{
hour = minute / 60;
minute = minute % 60;
}
second = second % 60;
}
else
{
minute = 0;
hour = 0;
}
//teacher = historyClass.Rows; <div class=\"xian\"> <img src=\"xuexijilu/xian.jpg\"></div>
time = hour + "时" + minute + "分" + second + "秒";
bfHistory += " <div class=\"column\"> <img src=\"xuexijilu/photo04.png\" class=\"photo\"> <div class=\"content\"> <h1><a target=\"_blank\" href=\"/wcm/outsite/study/Study.aspx?docId=" + dr["chapter_id"] + "&classId=" + dr["class_id"] + "&docNodeId=" + dr["docNodeId"] + "&productId=" + dr["product_id"] + "&bftime=" + Convert.ToInt32(dr["study_time"]) + "\">" + dr["title"].ToString() + "</a></h1> <p> 讲师:" + dr["teacher"].ToString() + "</p> <p> 学习进度:" + time + "</p><p> 学习日期 " + dr["create_time"].ToString() + "</p> </div></div>";--在css文件里面写页面代码元素
}