用asp.net串連資料庫,做登入頁面,怎麼弄呢。
辦法:
using System.Data.SqlClient;//記得加引用private bool Login(string sno,string sname){SqlConnection con = new SqlConnection("Data Source=資料庫連接;Initial Catalog=Stu_table;User ID=sa;Password=123456789");con.Open();string sql = string.Format("select count(*) from Student where Sno='{0}' and Sname='{1}'",sno,sname);//這裡你自己改改了,不知道你用什麼登陸的,帳號密碼不知道你用什麼欄位,暫時認為你用學號跟姓名登陸SqlCommand com = new SqlCommand(sql, con);int flag =(int) com.ExecuteScalar();con.Close();if (flag > 0){return true;}return false;}
//把上面的代碼放在login.aspx.cs裡面,你哪裡登陸就調用這個函數,傳登陸帳號跟密碼進來就行了.
//登陸成功就返回true,否則就返回false
//登陸成功你可以用下列語句跳轉到你那個頁面
Response.Redirect("裡面你跳轉的Url");
//登陸失敗你可以提示
Response.Write("<script> alert('帳號密碼錯誤');</script>");
//上面這個邏輯自己寫不出來的,那就真沒辦法了,小孩子都會了
//資料庫連接:這個你自己改,一般用 . 表示,你也可以自己開你的資料庫看。
問題:怎麼實現滑鼠跟隨事件與捲軸的綁定。
滑鼠跟隨事件在給了body高度之後,想要跟隨的圖片到一定位置之後就不在變化了,是為什麼。
代碼如下:
<!DOCTYPE html><html><head><meta charset="utf-8"><title>廣告</title></head><body style="height:1500px"><script type="text/javascript"> function badAD(html){ var gg=document.body.appendChild(document.createElement('div')); gg.style.cssText="border:1px solid pink;background:#000;position:absolute;"; gg.innerHTML=html||'This is bad idea!'; var c=gg.appendChild(document.createElement('span')); c.innerHTML="×"; c.style.cssText="position:absolute;right:4px;top:15px;cursor:pointer;color:red;font-weight:bold;"; c.onclick=function (){ document.onmousemove=null; this.parentNode.style.left='-99999px' }; document.onmousemove=function (e){ e=e||window.event; var x=e.clientX,y=e.clientY; setTimeout(function() { if(gg.hover)return; gg.style.left=x+5+'px'; gg.style.top=y+5+'px'; },120) } gg.onmouseover=function (){ this.hover=true }; gg.onmouseout=function (){ this.hover=false } } badAD('"一個連結"; "><img src="4.png"></a>') </script></body></html>
回答:
看這裡:var x=e.pageX,y=e.pageY;